@atlaskit/smart-card 17.7.1 → 17.7.4
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 +18 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +15 -7
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +3 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +7 -3
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +44 -11
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +7 -3
- package/dist/cjs/view/HoverCard/index.js +37 -0
- package/dist/cjs/view/HoverCard/styled.js +19 -0
- package/dist/cjs/view/HoverCard/types.js +5 -0
- package/dist/cjs/view/InlineCard/ResolvedView/index.js +15 -2
- package/dist/cjs/view/InlineCard/index.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +10 -4
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +3 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +6 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +34 -10
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +6 -2
- package/dist/es2019/view/HoverCard/index.js +20 -0
- package/dist/es2019/view/HoverCard/styled.js +9 -0
- package/dist/es2019/view/HoverCard/types.js +1 -0
- package/dist/es2019/view/InlineCard/ResolvedView/index.js +12 -2
- package/dist/es2019/view/InlineCard/index.js +3 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +15 -7
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +3 -2
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +7 -3
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +35 -11
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +7 -3
- package/dist/esm/view/HoverCard/index.js +19 -0
- package/dist/esm/view/HoverCard/styled.js +7 -0
- package/dist/esm/view/HoverCard/types.js +1 -0
- package/dist/esm/view/InlineCard/ResolvedView/index.js +13 -2
- package/dist/esm/view/InlineCard/index.js +3 -1
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/blocks/title-block/resolved/index.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +2 -0
- package/dist/types/view/HoverCard/index.d.ts +3 -0
- package/dist/types/view/HoverCard/styled.d.ts +2 -0
- package/dist/types/view/HoverCard/types.d.ts +3 -0
- package/dist/types/view/InlineCard/ResolvedView/index.d.ts +2 -0
- package/dist/types/view/InlineCard/types.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 17.7.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ff7b1126682`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ff7b1126682) - Set up base component and relevant tests for hover previews
|
|
8
|
+
|
|
9
|
+
## 17.7.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`474d69913ef`](https://bitbucket.org/atlassian/atlassian-frontend/commits/474d69913ef) - Title block can have an action visible only on hover
|
|
14
|
+
|
|
15
|
+
## 17.7.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`9066a1e8154`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9066a1e8154) - EDM-2926: Add title override for title block
|
|
20
|
+
|
|
3
21
|
## 17.7.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/version.json
CHANGED
|
@@ -40,18 +40,26 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
40
40
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
41
41
|
_ref$size = _ref.size,
|
|
42
42
|
size = _ref$size === void 0 ? _constants.SmartLinkSize.Medium : _ref$size,
|
|
43
|
-
appearance = _ref.appearance
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
appearance = _ref.appearance,
|
|
44
|
+
_ref$visibleButtonsNu = _ref.visibleButtonsNum,
|
|
45
|
+
visibleButtonsNum = _ref$visibleButtonsNu === void 0 ? 2 : _ref$visibleButtonsNu,
|
|
46
|
+
onDropdownOpenChange = _ref.onDropdownOpenChange;
|
|
47
|
+
var isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
48
|
+
var firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
49
|
+
var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
47
50
|
return (0, _core.jsx)("div", {
|
|
48
51
|
css: styles
|
|
49
52
|
}, (0, _core.jsx)(_buttonGroup.default, null, (0, _utils.renderActionItems)(firstActions, size, appearance), restActions.length > 0 ? (0, _core.jsx)(_dropdownMenu.default, {
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
+
onOpenChange: function onOpenChange(_ref2) {
|
|
54
|
+
var isOpen = _ref2.isOpen;
|
|
55
|
+
return onDropdownOpenChange && onDropdownOpenChange(isOpen);
|
|
56
|
+
},
|
|
57
|
+
trigger: function trigger(_ref3) {
|
|
58
|
+
var triggerRef = _ref3.triggerRef,
|
|
59
|
+
props = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
|
|
53
60
|
return (0, _core.jsx)(_standardButton.default, (0, _extends2.default)({}, props, {
|
|
54
61
|
spacing: _action.sizeToSpacing[size],
|
|
62
|
+
className: "action-group-more-button",
|
|
55
63
|
testId: "action-group-more-button",
|
|
56
64
|
iconBefore: (0, _core.jsx)(_more.default, {
|
|
57
65
|
label: "more"
|
|
@@ -30,9 +30,10 @@ var Block = function Block(_ref) {
|
|
|
30
30
|
_ref$size = _ref.size,
|
|
31
31
|
size = _ref$size === void 0 ? _constants.SmartLinkSize.Medium : _ref$size,
|
|
32
32
|
_ref$testId = _ref.testId,
|
|
33
|
-
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId
|
|
33
|
+
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId,
|
|
34
|
+
extraCss = _ref.extraCss;
|
|
34
35
|
return (0, _core.jsx)("div", {
|
|
35
|
-
css: getBlockStyles(direction, size),
|
|
36
|
+
css: [getBlockStyles(direction, size), extraCss],
|
|
36
37
|
"data-smart-block": true,
|
|
37
38
|
"data-testid": testId
|
|
38
39
|
}, (0, _utils.renderChildren)(children, size));
|
|
@@ -31,7 +31,7 @@ var _elementGroup = _interopRequireDefault(require("../../element-group"));
|
|
|
31
31
|
|
|
32
32
|
var _token = require("../../../../../../utils/token");
|
|
33
33
|
|
|
34
|
-
var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
|
|
34
|
+
var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
|
|
35
35
|
|
|
36
36
|
var _templateObject, _templateObject2;
|
|
37
37
|
|
|
@@ -48,6 +48,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
|
48
48
|
position = _ref.position,
|
|
49
49
|
testId = _ref.testId,
|
|
50
50
|
theme = _ref.theme,
|
|
51
|
+
text = _ref.text,
|
|
51
52
|
blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
52
53
|
|
|
53
54
|
var _ref2 = retry || {},
|
|
@@ -58,14 +59,17 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
|
58
59
|
var _blockProps$size = blockProps.size,
|
|
59
60
|
size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
|
|
60
61
|
var hasAction = onClick !== undefined;
|
|
62
|
+
var overrideText = !!text ? {
|
|
63
|
+
text: text
|
|
64
|
+
} : {};
|
|
61
65
|
return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
|
|
62
66
|
testId: "".concat(testId, "-errored-view")
|
|
63
67
|
}), (0, _core.jsx)(_elements.LinkIcon, {
|
|
64
68
|
position: position
|
|
65
|
-
}), (0, _core.jsx)(_elements.Title, {
|
|
69
|
+
}), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
|
|
66
70
|
maxLines: maxLines,
|
|
67
71
|
theme: theme
|
|
68
|
-
}), descriptor && (0, _core.jsx)(_elementGroup.default, {
|
|
72
|
+
})), descriptor && (0, _core.jsx)(_elementGroup.default, {
|
|
69
73
|
direction: _constants.SmartLinkDirection.Horizontal,
|
|
70
74
|
align: _constants.SmartLinkAlignment.Right
|
|
71
75
|
}, (0, _core.jsx)("span", {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -9,9 +11,15 @@ exports.default = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
12
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
17
|
|
|
14
|
-
var
|
|
18
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _core = require("@emotion/core");
|
|
15
23
|
|
|
16
24
|
var _elements = require("../../../elements");
|
|
17
25
|
|
|
@@ -25,7 +33,15 @@ var _utils = require("../../utils");
|
|
|
25
33
|
|
|
26
34
|
var _actionGroup = _interopRequireDefault(require("../../action-group"));
|
|
27
35
|
|
|
28
|
-
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme"];
|
|
36
|
+
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text", "showActionOnHover"];
|
|
37
|
+
|
|
38
|
+
var _templateObject;
|
|
39
|
+
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
|
+
|
|
42
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
+
|
|
44
|
+
var actionOnHoverOnlyStyle = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
|
|
29
45
|
|
|
30
46
|
var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
31
47
|
var maxLines = _ref.maxLines,
|
|
@@ -38,26 +54,43 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
38
54
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
39
55
|
testId = _ref.testId,
|
|
40
56
|
theme = _ref.theme,
|
|
57
|
+
text = _ref.text,
|
|
58
|
+
showActionOnHover = _ref.showActionOnHover,
|
|
41
59
|
blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
60
|
+
|
|
61
|
+
var _useState = (0, _react.useState)(false),
|
|
62
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
63
|
+
actionDropdownOpen = _useState2[0],
|
|
64
|
+
setActionDropdownOpen = _useState2[1];
|
|
65
|
+
|
|
42
66
|
var metadataElements = (0, _utils.renderElementItems)(metadata);
|
|
43
67
|
var subtitleElements = (0, _utils.renderElementItems)(subtitle);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
68
|
+
var overrideText = !!text ? {
|
|
69
|
+
text: text
|
|
70
|
+
} : {};
|
|
71
|
+
var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
|
|
72
|
+
return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
|
|
73
|
+
testId: "".concat(testId, "-resolved-view"),
|
|
74
|
+
extraCss: extraCss
|
|
75
|
+
}), (0, _core.jsx)(_elements.LinkIcon, {
|
|
47
76
|
position: position
|
|
48
|
-
}),
|
|
77
|
+
}), (0, _core.jsx)(_elementGroup.default, {
|
|
49
78
|
direction: _constants.SmartLinkDirection.Vertical,
|
|
50
79
|
width: _constants.SmartLinkWidth.Flexible
|
|
51
|
-
},
|
|
80
|
+
}, (0, _core.jsx)(_elements.Title, (0, _extends2.default)({
|
|
52
81
|
maxLines: maxLines,
|
|
53
82
|
theme: theme
|
|
54
|
-
}), subtitleElements &&
|
|
83
|
+
}, overrideText)), subtitleElements && (0, _core.jsx)(_elementGroup.default, {
|
|
55
84
|
direction: _constants.SmartLinkDirection.Horizontal
|
|
56
|
-
}, subtitleElements)), metadataElements &&
|
|
85
|
+
}, subtitleElements)), metadataElements && (0, _core.jsx)(_elementGroup.default, {
|
|
57
86
|
direction: _constants.SmartLinkDirection.Horizontal,
|
|
58
87
|
align: _constants.SmartLinkAlignment.Right
|
|
59
|
-
}, metadataElements), actions.length > 0 &&
|
|
60
|
-
items: actions
|
|
88
|
+
}, metadataElements), actions.length > 0 && (0, _core.jsx)(_actionGroup.default, {
|
|
89
|
+
items: actions,
|
|
90
|
+
visibleButtonsNum: showActionOnHover ? 1 : 2,
|
|
91
|
+
onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
|
|
92
|
+
return setActionDropdownOpen(isOpen);
|
|
93
|
+
}
|
|
61
94
|
}));
|
|
62
95
|
};
|
|
63
96
|
|
|
@@ -23,7 +23,7 @@ var _block = _interopRequireDefault(require("../../block"));
|
|
|
23
23
|
|
|
24
24
|
var _constants = require("../../../../../../constants");
|
|
25
25
|
|
|
26
|
-
var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
|
|
26
|
+
var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
|
|
27
27
|
|
|
28
28
|
var getSpinnerSize = function getSpinnerSize(size) {
|
|
29
29
|
// Spinner sizes should be equivalent or smaller than Icon size
|
|
@@ -50,18 +50,22 @@ var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
|
|
|
50
50
|
position = _ref.position,
|
|
51
51
|
testId = _ref.testId,
|
|
52
52
|
theme = _ref.theme,
|
|
53
|
+
text = _ref.text,
|
|
53
54
|
blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
54
55
|
var _blockProps$size = blockProps.size,
|
|
55
56
|
size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
|
|
57
|
+
var overrideText = !!text ? {
|
|
58
|
+
text: text
|
|
59
|
+
} : {};
|
|
56
60
|
return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
|
|
57
61
|
testId: "".concat(testId, "-resolving-view")
|
|
58
62
|
}), (0, _core.jsx)(_spinner.default, {
|
|
59
63
|
size: getSpinnerSize(size),
|
|
60
64
|
testId: "".concat(testId, "-resolving-spinner")
|
|
61
|
-
}), (0, _core.jsx)(_elements.Title, {
|
|
65
|
+
}), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
|
|
62
66
|
maxLines: maxLines,
|
|
63
67
|
theme: theme
|
|
64
|
-
}));
|
|
68
|
+
})));
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
var _default = TitleBlockResolvingView;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HoverCard = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
13
|
+
|
|
14
|
+
var _blocks = require("../FlexibleCard/components/blocks");
|
|
15
|
+
|
|
16
|
+
var _Card = require("../Card");
|
|
17
|
+
|
|
18
|
+
var _styled = require("./styled");
|
|
19
|
+
|
|
20
|
+
var HoverCard = function HoverCard(_ref) {
|
|
21
|
+
var children = _ref.children,
|
|
22
|
+
url = _ref.url;
|
|
23
|
+
|
|
24
|
+
var cardComponent = /*#__PURE__*/_react.default.createElement(_Card.Card, {
|
|
25
|
+
appearance: "block",
|
|
26
|
+
url: url
|
|
27
|
+
}, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, null), /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, null), /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, null));
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
30
|
+
content: cardComponent,
|
|
31
|
+
component: _styled.HoverCardContainer,
|
|
32
|
+
testId: "hover-card",
|
|
33
|
+
tag: "span"
|
|
34
|
+
}, children);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.HoverCard = HoverCard;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HoverCardContainer = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
13
|
+
|
|
14
|
+
var _tooltip = require("@atlaskit/tooltip");
|
|
15
|
+
|
|
16
|
+
var _templateObject;
|
|
17
|
+
|
|
18
|
+
var HoverCardContainer = (0, _styled.default)(_tooltip.TooltipPrimitive)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background: none;\n border-width: 0;\n box-sizing: content-box; /* do not set this to border-box or it will break the overflow handling */\n max-width: 500px;\n padding: 0;\n"])));
|
|
19
|
+
exports.HoverCardContainer = HoverCardContainer;
|
|
@@ -27,6 +27,8 @@ var _IconAndTitleLayout = require("../IconAndTitleLayout");
|
|
|
27
27
|
|
|
28
28
|
var _styled = require("../IconAndTitleLayout/styled");
|
|
29
29
|
|
|
30
|
+
var _index = require("../../../view/HoverCard/index");
|
|
31
|
+
|
|
30
32
|
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); }; }
|
|
31
33
|
|
|
32
34
|
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; } }
|
|
@@ -68,8 +70,11 @@ var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
68
70
|
_this$props$testId = _this$props.testId,
|
|
69
71
|
testId = _this$props$testId === void 0 ? 'inline-card-resolved-view' : _this$props$testId,
|
|
70
72
|
titleTextColor = _this$props.titleTextColor,
|
|
71
|
-
titlePrefix = _this$props.titlePrefix
|
|
72
|
-
|
|
73
|
+
titlePrefix = _this$props.titlePrefix,
|
|
74
|
+
_this$props$showHover = _this$props.showHoverPreview,
|
|
75
|
+
showHoverPreview = _this$props$showHover === void 0 ? false : _this$props$showHover;
|
|
76
|
+
|
|
77
|
+
var inlineCardResolvedView = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
|
|
73
78
|
testId: testId,
|
|
74
79
|
link: link,
|
|
75
80
|
isSelected: isSelected,
|
|
@@ -80,6 +85,14 @@ var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
80
85
|
title: title,
|
|
81
86
|
titleTextColor: titleTextColor
|
|
82
87
|
}), this.renderLozenge());
|
|
88
|
+
|
|
89
|
+
if (showHoverPreview && link) {
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_index.HoverCard, {
|
|
91
|
+
url: link
|
|
92
|
+
}, inlineCardResolvedView);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return inlineCardResolvedView;
|
|
83
96
|
}
|
|
84
97
|
}]);
|
|
85
98
|
return InlineCardResolvedView;
|
|
@@ -70,7 +70,8 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
70
70
|
renderers = _ref.renderers,
|
|
71
71
|
onResolve = _ref.onResolve,
|
|
72
72
|
testId = _ref.testId,
|
|
73
|
-
inlinePreloaderStyle = _ref.inlinePreloaderStyle
|
|
73
|
+
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
74
|
+
showHoverPreview = _ref.showHoverPreview;
|
|
74
75
|
var status = cardState.status,
|
|
75
76
|
details = cardState.details;
|
|
76
77
|
var cardDetails = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
@@ -98,6 +99,7 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
return /*#__PURE__*/_react.default.createElement(_ResolvedView.InlineCardResolvedView, (0, _extends2.default)({}, resolvedProps, {
|
|
102
|
+
showHoverPreview: showHoverPreview,
|
|
101
103
|
link: url,
|
|
102
104
|
isSelected: isSelected,
|
|
103
105
|
onClick: handleFrameClick,
|
package/dist/es2019/version.json
CHANGED
|
@@ -17,19 +17,25 @@ const styles = css`
|
|
|
17
17
|
const ActionGroup = ({
|
|
18
18
|
items = [],
|
|
19
19
|
size = SmartLinkSize.Medium,
|
|
20
|
-
appearance
|
|
20
|
+
appearance,
|
|
21
|
+
visibleButtonsNum = 2,
|
|
22
|
+
onDropdownOpenChange
|
|
21
23
|
}) => {
|
|
22
|
-
const isMoreThenTwoItems = items.length >
|
|
23
|
-
const firstActions = isMoreThenTwoItems ? items.slice(0, 1) : items;
|
|
24
|
-
const restActions = isMoreThenTwoItems ? items.slice(1) : [];
|
|
24
|
+
const isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
25
|
+
const firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
26
|
+
const restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
25
27
|
return jsx("div", {
|
|
26
28
|
css: styles
|
|
27
29
|
}, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
|
|
30
|
+
onOpenChange: ({
|
|
31
|
+
isOpen
|
|
32
|
+
}) => onDropdownOpenChange && onDropdownOpenChange(isOpen),
|
|
28
33
|
trigger: ({
|
|
29
34
|
triggerRef,
|
|
30
35
|
...props
|
|
31
36
|
}) => jsx(Button, _extends({}, props, {
|
|
32
37
|
spacing: sizeToSpacing[size],
|
|
38
|
+
className: "action-group-more-button",
|
|
33
39
|
testId: "action-group-more-button",
|
|
34
40
|
iconBefore: jsx(MoreIcon, {
|
|
35
41
|
label: "more"
|
|
@@ -13,9 +13,10 @@ const Block = ({
|
|
|
13
13
|
children,
|
|
14
14
|
direction = SmartLinkDirection.Horizontal,
|
|
15
15
|
size = SmartLinkSize.Medium,
|
|
16
|
-
testId = 'smart-block'
|
|
16
|
+
testId = 'smart-block',
|
|
17
|
+
extraCss
|
|
17
18
|
}) => jsx("div", {
|
|
18
|
-
css: getBlockStyles(direction, size),
|
|
19
|
+
css: [getBlockStyles(direction, size), extraCss],
|
|
19
20
|
"data-smart-block": true,
|
|
20
21
|
"data-testid": testId
|
|
21
22
|
}, renderChildren(children, size));
|
|
@@ -36,6 +36,7 @@ const TitleBlockErroredView = ({
|
|
|
36
36
|
position,
|
|
37
37
|
testId,
|
|
38
38
|
theme,
|
|
39
|
+
text,
|
|
39
40
|
...blockProps
|
|
40
41
|
}) => {
|
|
41
42
|
const {
|
|
@@ -47,14 +48,17 @@ const TitleBlockErroredView = ({
|
|
|
47
48
|
size = SmartLinkSize.Medium
|
|
48
49
|
} = blockProps;
|
|
49
50
|
const hasAction = onClick !== undefined;
|
|
51
|
+
const overrideText = !!text ? {
|
|
52
|
+
text
|
|
53
|
+
} : {};
|
|
50
54
|
return jsx(Block, _extends({}, blockProps, {
|
|
51
55
|
testId: `${testId}-errored-view`
|
|
52
56
|
}), jsx(LinkIcon, {
|
|
53
57
|
position: position
|
|
54
|
-
}), jsx(Title, {
|
|
58
|
+
}), jsx(Title, _extends({}, overrideText, {
|
|
55
59
|
maxLines: maxLines,
|
|
56
60
|
theme: theme
|
|
57
|
-
}), descriptor && jsx(ElementGroup, {
|
|
61
|
+
})), descriptor && jsx(ElementGroup, {
|
|
58
62
|
direction: SmartLinkDirection.Horizontal,
|
|
59
63
|
align: SmartLinkAlignment.Right
|
|
60
64
|
}, jsx("span", {
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
3
6
|
import { LinkIcon, Title } from '../../../elements';
|
|
4
7
|
import Block from '../../block';
|
|
5
8
|
import ElementGroup from '../../element-group';
|
|
6
9
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
|
|
7
10
|
import { renderElementItems } from '../../utils';
|
|
8
11
|
import ActionGroup from '../../action-group';
|
|
12
|
+
const actionOnHoverOnlyStyle = css`
|
|
13
|
+
.action-group-more-button {
|
|
14
|
+
visibility: hidden;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
.action-group-more-button {
|
|
19
|
+
visibility: visible;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
9
23
|
|
|
10
24
|
const TitleBlockResolvedView = ({
|
|
11
25
|
maxLines,
|
|
@@ -15,27 +29,37 @@ const TitleBlockResolvedView = ({
|
|
|
15
29
|
actions = [],
|
|
16
30
|
testId,
|
|
17
31
|
theme,
|
|
32
|
+
text,
|
|
33
|
+
showActionOnHover,
|
|
18
34
|
...blockProps
|
|
19
35
|
}) => {
|
|
36
|
+
const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
|
|
20
37
|
const metadataElements = renderElementItems(metadata);
|
|
21
38
|
const subtitleElements = renderElementItems(subtitle);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
39
|
+
const overrideText = !!text ? {
|
|
40
|
+
text
|
|
41
|
+
} : {};
|
|
42
|
+
const extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
|
|
43
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
44
|
+
testId: `${testId}-resolved-view`,
|
|
45
|
+
extraCss: extraCss
|
|
46
|
+
}), jsx(LinkIcon, {
|
|
25
47
|
position: position
|
|
26
|
-
}),
|
|
48
|
+
}), jsx(ElementGroup, {
|
|
27
49
|
direction: SmartLinkDirection.Vertical,
|
|
28
50
|
width: SmartLinkWidth.Flexible
|
|
29
|
-
},
|
|
51
|
+
}, jsx(Title, _extends({
|
|
30
52
|
maxLines: maxLines,
|
|
31
53
|
theme: theme
|
|
32
|
-
}), subtitleElements &&
|
|
54
|
+
}, overrideText)), subtitleElements && jsx(ElementGroup, {
|
|
33
55
|
direction: SmartLinkDirection.Horizontal
|
|
34
|
-
}, subtitleElements)), metadataElements &&
|
|
56
|
+
}, subtitleElements)), metadataElements && jsx(ElementGroup, {
|
|
35
57
|
direction: SmartLinkDirection.Horizontal,
|
|
36
58
|
align: SmartLinkAlignment.Right
|
|
37
|
-
}, metadataElements), actions.length > 0 &&
|
|
38
|
-
items: actions
|
|
59
|
+
}, metadataElements), actions.length > 0 && jsx(ActionGroup, {
|
|
60
|
+
items: actions,
|
|
61
|
+
visibleButtonsNum: showActionOnHover ? 1 : 2,
|
|
62
|
+
onDropdownOpenChange: isOpen => setActionDropdownOpen(isOpen)
|
|
39
63
|
}));
|
|
40
64
|
};
|
|
41
65
|
|
|
@@ -33,20 +33,24 @@ const TitleBlockResolvingView = ({
|
|
|
33
33
|
position,
|
|
34
34
|
testId,
|
|
35
35
|
theme,
|
|
36
|
+
text,
|
|
36
37
|
...blockProps
|
|
37
38
|
}) => {
|
|
38
39
|
const {
|
|
39
40
|
size = SmartLinkSize.Medium
|
|
40
41
|
} = blockProps;
|
|
42
|
+
const overrideText = !!text ? {
|
|
43
|
+
text
|
|
44
|
+
} : {};
|
|
41
45
|
return jsx(Block, _extends({}, blockProps, {
|
|
42
46
|
testId: `${testId}-resolving-view`
|
|
43
47
|
}), jsx(Spinner, {
|
|
44
48
|
size: getSpinnerSize(size),
|
|
45
49
|
testId: `${testId}-resolving-spinner`
|
|
46
|
-
}), jsx(Title, {
|
|
50
|
+
}), jsx(Title, _extends({}, overrideText, {
|
|
47
51
|
maxLines: maxLines,
|
|
48
52
|
theme: theme
|
|
49
|
-
}));
|
|
53
|
+
})));
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
export default TitleBlockResolvingView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
3
|
+
import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
|
|
4
|
+
import { Card } from '../Card';
|
|
5
|
+
import { HoverCardContainer } from './styled';
|
|
6
|
+
export const HoverCard = ({
|
|
7
|
+
children,
|
|
8
|
+
url
|
|
9
|
+
}) => {
|
|
10
|
+
const cardComponent = /*#__PURE__*/React.createElement(Card, {
|
|
11
|
+
appearance: "block",
|
|
12
|
+
url: url
|
|
13
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(FooterBlock, null));
|
|
14
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
15
|
+
content: cardComponent,
|
|
16
|
+
component: HoverCardContainer,
|
|
17
|
+
testId: "hover-card",
|
|
18
|
+
tag: "span"
|
|
19
|
+
}, children);
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { TooltipPrimitive } from '@atlaskit/tooltip';
|
|
3
|
+
export const HoverCardContainer = styled(TooltipPrimitive)`
|
|
4
|
+
background: none;
|
|
5
|
+
border-width: 0;
|
|
6
|
+
box-sizing: content-box; /* do not set this to border-box or it will break the overflow handling */
|
|
7
|
+
max-width: 500px;
|
|
8
|
+
padding: 0;
|
|
9
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import { Frame } from '../Frame';
|
|
|
3
3
|
import Lozenge from '@atlaskit/lozenge';
|
|
4
4
|
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
5
5
|
import { LozengeWrapper } from '../IconAndTitleLayout/styled';
|
|
6
|
+
import { HoverCard } from '../../../view/HoverCard/index';
|
|
6
7
|
export class InlineCardResolvedView extends React.Component {
|
|
7
8
|
renderLozenge() {
|
|
8
9
|
const {
|
|
@@ -28,9 +29,10 @@ export class InlineCardResolvedView extends React.Component {
|
|
|
28
29
|
link,
|
|
29
30
|
testId = 'inline-card-resolved-view',
|
|
30
31
|
titleTextColor,
|
|
31
|
-
titlePrefix
|
|
32
|
+
titlePrefix,
|
|
33
|
+
showHoverPreview = false
|
|
32
34
|
} = this.props;
|
|
33
|
-
|
|
35
|
+
const inlineCardResolvedView = /*#__PURE__*/React.createElement(Frame, {
|
|
34
36
|
testId: testId,
|
|
35
37
|
link: link,
|
|
36
38
|
isSelected: isSelected,
|
|
@@ -41,6 +43,14 @@ export class InlineCardResolvedView extends React.Component {
|
|
|
41
43
|
title: title,
|
|
42
44
|
titleTextColor: titleTextColor
|
|
43
45
|
}), this.renderLozenge());
|
|
46
|
+
|
|
47
|
+
if (showHoverPreview && link) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
49
|
+
url: link
|
|
50
|
+
}, inlineCardResolvedView);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return inlineCardResolvedView;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
}
|
|
@@ -19,7 +19,8 @@ export const InlineCard = ({
|
|
|
19
19
|
renderers,
|
|
20
20
|
onResolve,
|
|
21
21
|
testId,
|
|
22
|
-
inlinePreloaderStyle
|
|
22
|
+
inlinePreloaderStyle,
|
|
23
|
+
showHoverPreview
|
|
23
24
|
}) => {
|
|
24
25
|
var _details$meta;
|
|
25
26
|
|
|
@@ -52,6 +53,7 @@ export const InlineCard = ({
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedProps, {
|
|
56
|
+
showHoverPreview: showHoverPreview,
|
|
55
57
|
link: url,
|
|
56
58
|
isSelected: isSelected,
|
|
57
59
|
onClick: handleFrameClick,
|
package/dist/esm/version.json
CHANGED
|
@@ -21,19 +21,27 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
21
21
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
22
22
|
_ref$size = _ref.size,
|
|
23
23
|
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
24
|
-
appearance = _ref.appearance
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
appearance = _ref.appearance,
|
|
25
|
+
_ref$visibleButtonsNu = _ref.visibleButtonsNum,
|
|
26
|
+
visibleButtonsNum = _ref$visibleButtonsNu === void 0 ? 2 : _ref$visibleButtonsNu,
|
|
27
|
+
onDropdownOpenChange = _ref.onDropdownOpenChange;
|
|
28
|
+
var isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
29
|
+
var firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
30
|
+
var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
28
31
|
return jsx("div", {
|
|
29
32
|
css: styles
|
|
30
33
|
}, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
+
onOpenChange: function onOpenChange(_ref2) {
|
|
35
|
+
var isOpen = _ref2.isOpen;
|
|
36
|
+
return onDropdownOpenChange && onDropdownOpenChange(isOpen);
|
|
37
|
+
},
|
|
38
|
+
trigger: function trigger(_ref3) {
|
|
39
|
+
var triggerRef = _ref3.triggerRef,
|
|
40
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
34
41
|
|
|
35
42
|
return jsx(Button, _extends({}, props, {
|
|
36
43
|
spacing: sizeToSpacing[size],
|
|
44
|
+
className: "action-group-more-button",
|
|
37
45
|
testId: "action-group-more-button",
|
|
38
46
|
iconBefore: jsx(MoreIcon, {
|
|
39
47
|
label: "more"
|
|
@@ -19,9 +19,10 @@ var Block = function Block(_ref) {
|
|
|
19
19
|
_ref$size = _ref.size,
|
|
20
20
|
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
21
21
|
_ref$testId = _ref.testId,
|
|
22
|
-
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId
|
|
22
|
+
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId,
|
|
23
|
+
extraCss = _ref.extraCss;
|
|
23
24
|
return jsx("div", {
|
|
24
|
-
css: getBlockStyles(direction, size),
|
|
25
|
+
css: [getBlockStyles(direction, size), extraCss],
|
|
25
26
|
"data-smart-block": true,
|
|
26
27
|
"data-testid": testId
|
|
27
28
|
}, renderChildren(children, size));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
-
var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
|
|
4
|
+
var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
|
|
5
5
|
|
|
6
6
|
var _templateObject, _templateObject2;
|
|
7
7
|
|
|
@@ -28,6 +28,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
|
28
28
|
position = _ref.position,
|
|
29
29
|
testId = _ref.testId,
|
|
30
30
|
theme = _ref.theme,
|
|
31
|
+
text = _ref.text,
|
|
31
32
|
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
33
|
|
|
33
34
|
var _ref2 = retry || {},
|
|
@@ -38,14 +39,17 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
|
38
39
|
var _blockProps$size = blockProps.size,
|
|
39
40
|
size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
|
|
40
41
|
var hasAction = onClick !== undefined;
|
|
42
|
+
var overrideText = !!text ? {
|
|
43
|
+
text: text
|
|
44
|
+
} : {};
|
|
41
45
|
return jsx(Block, _extends({}, blockProps, {
|
|
42
46
|
testId: "".concat(testId, "-errored-view")
|
|
43
47
|
}), jsx(LinkIcon, {
|
|
44
48
|
position: position
|
|
45
|
-
}), jsx(Title, {
|
|
49
|
+
}), jsx(Title, _extends({}, overrideText, {
|
|
46
50
|
maxLines: maxLines,
|
|
47
51
|
theme: theme
|
|
48
|
-
}), descriptor && jsx(ElementGroup, {
|
|
52
|
+
})), descriptor && jsx(ElementGroup, {
|
|
49
53
|
direction: SmartLinkDirection.Horizontal,
|
|
50
54
|
align: SmartLinkAlignment.Right
|
|
51
55
|
}, jsx("span", {
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
|
+
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text", "showActionOnHover"];
|
|
6
|
+
|
|
7
|
+
var _templateObject;
|
|
8
|
+
|
|
9
|
+
/** @jsx jsx */
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
import { css, jsx } from '@emotion/core';
|
|
5
12
|
import { LinkIcon, Title } from '../../../elements';
|
|
6
13
|
import Block from '../../block';
|
|
7
14
|
import ElementGroup from '../../element-group';
|
|
8
15
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
|
|
9
16
|
import { renderElementItems } from '../../utils';
|
|
10
17
|
import ActionGroup from '../../action-group';
|
|
18
|
+
var actionOnHoverOnlyStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
|
|
11
19
|
|
|
12
20
|
var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
13
21
|
var maxLines = _ref.maxLines,
|
|
@@ -20,27 +28,43 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
20
28
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
21
29
|
testId = _ref.testId,
|
|
22
30
|
theme = _ref.theme,
|
|
31
|
+
text = _ref.text,
|
|
32
|
+
showActionOnHover = _ref.showActionOnHover,
|
|
23
33
|
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
24
34
|
|
|
35
|
+
var _useState = useState(false),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
actionDropdownOpen = _useState2[0],
|
|
38
|
+
setActionDropdownOpen = _useState2[1];
|
|
39
|
+
|
|
25
40
|
var metadataElements = renderElementItems(metadata);
|
|
26
41
|
var subtitleElements = renderElementItems(subtitle);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
42
|
+
var overrideText = !!text ? {
|
|
43
|
+
text: text
|
|
44
|
+
} : {};
|
|
45
|
+
var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
|
|
46
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
47
|
+
testId: "".concat(testId, "-resolved-view"),
|
|
48
|
+
extraCss: extraCss
|
|
49
|
+
}), jsx(LinkIcon, {
|
|
30
50
|
position: position
|
|
31
|
-
}),
|
|
51
|
+
}), jsx(ElementGroup, {
|
|
32
52
|
direction: SmartLinkDirection.Vertical,
|
|
33
53
|
width: SmartLinkWidth.Flexible
|
|
34
|
-
},
|
|
54
|
+
}, jsx(Title, _extends({
|
|
35
55
|
maxLines: maxLines,
|
|
36
56
|
theme: theme
|
|
37
|
-
}), subtitleElements &&
|
|
57
|
+
}, overrideText)), subtitleElements && jsx(ElementGroup, {
|
|
38
58
|
direction: SmartLinkDirection.Horizontal
|
|
39
|
-
}, subtitleElements)), metadataElements &&
|
|
59
|
+
}, subtitleElements)), metadataElements && jsx(ElementGroup, {
|
|
40
60
|
direction: SmartLinkDirection.Horizontal,
|
|
41
61
|
align: SmartLinkAlignment.Right
|
|
42
|
-
}, metadataElements), actions.length > 0 &&
|
|
43
|
-
items: actions
|
|
62
|
+
}, metadataElements), actions.length > 0 && jsx(ActionGroup, {
|
|
63
|
+
items: actions,
|
|
64
|
+
visibleButtonsNum: showActionOnHover ? 1 : 2,
|
|
65
|
+
onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
|
|
66
|
+
return setActionDropdownOpen(isOpen);
|
|
67
|
+
}
|
|
44
68
|
}));
|
|
45
69
|
};
|
|
46
70
|
|
|
@@ -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 = ["maxLines", "retry", "position", "testId", "theme"];
|
|
3
|
+
var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React from 'react';
|
|
@@ -35,19 +35,23 @@ var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
|
|
|
35
35
|
position = _ref.position,
|
|
36
36
|
testId = _ref.testId,
|
|
37
37
|
theme = _ref.theme,
|
|
38
|
+
text = _ref.text,
|
|
38
39
|
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
39
40
|
|
|
40
41
|
var _blockProps$size = blockProps.size,
|
|
41
42
|
size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
|
|
43
|
+
var overrideText = !!text ? {
|
|
44
|
+
text: text
|
|
45
|
+
} : {};
|
|
42
46
|
return jsx(Block, _extends({}, blockProps, {
|
|
43
47
|
testId: "".concat(testId, "-resolving-view")
|
|
44
48
|
}), jsx(Spinner, {
|
|
45
49
|
size: getSpinnerSize(size),
|
|
46
50
|
testId: "".concat(testId, "-resolving-spinner")
|
|
47
|
-
}), jsx(Title, {
|
|
51
|
+
}), jsx(Title, _extends({}, overrideText, {
|
|
48
52
|
maxLines: maxLines,
|
|
49
53
|
theme: theme
|
|
50
|
-
}));
|
|
54
|
+
})));
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
export default TitleBlockResolvingView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
3
|
+
import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
|
|
4
|
+
import { Card } from '../Card';
|
|
5
|
+
import { HoverCardContainer } from './styled';
|
|
6
|
+
export var HoverCard = function HoverCard(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
url = _ref.url;
|
|
9
|
+
var cardComponent = /*#__PURE__*/React.createElement(Card, {
|
|
10
|
+
appearance: "block",
|
|
11
|
+
url: url
|
|
12
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(FooterBlock, null));
|
|
13
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
14
|
+
content: cardComponent,
|
|
15
|
+
component: HoverCardContainer,
|
|
16
|
+
testId: "hover-card",
|
|
17
|
+
tag: "span"
|
|
18
|
+
}, children);
|
|
19
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import styled from '@emotion/styled';
|
|
6
|
+
import { TooltipPrimitive } from '@atlaskit/tooltip';
|
|
7
|
+
export var HoverCardContainer = styled(TooltipPrimitive)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n box-sizing: content-box; /* do not set this to border-box or it will break the overflow handling */\n max-width: 500px;\n padding: 0;\n"])));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -13,6 +13,7 @@ import { Frame } from '../Frame';
|
|
|
13
13
|
import Lozenge from '@atlaskit/lozenge';
|
|
14
14
|
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
15
15
|
import { LozengeWrapper } from '../IconAndTitleLayout/styled';
|
|
16
|
+
import { HoverCard } from '../../../view/HoverCard/index';
|
|
16
17
|
export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
17
18
|
_inherits(InlineCardResolvedView, _React$Component);
|
|
18
19
|
|
|
@@ -51,8 +52,10 @@ export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
51
52
|
_this$props$testId = _this$props.testId,
|
|
52
53
|
testId = _this$props$testId === void 0 ? 'inline-card-resolved-view' : _this$props$testId,
|
|
53
54
|
titleTextColor = _this$props.titleTextColor,
|
|
54
|
-
titlePrefix = _this$props.titlePrefix
|
|
55
|
-
|
|
55
|
+
titlePrefix = _this$props.titlePrefix,
|
|
56
|
+
_this$props$showHover = _this$props.showHoverPreview,
|
|
57
|
+
showHoverPreview = _this$props$showHover === void 0 ? false : _this$props$showHover;
|
|
58
|
+
var inlineCardResolvedView = /*#__PURE__*/React.createElement(Frame, {
|
|
56
59
|
testId: testId,
|
|
57
60
|
link: link,
|
|
58
61
|
isSelected: isSelected,
|
|
@@ -63,6 +66,14 @@ export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
63
66
|
title: title,
|
|
64
67
|
titleTextColor: titleTextColor
|
|
65
68
|
}), this.renderLozenge());
|
|
69
|
+
|
|
70
|
+
if (showHoverPreview && link) {
|
|
71
|
+
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
72
|
+
url: link
|
|
73
|
+
}, inlineCardResolvedView);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return inlineCardResolvedView;
|
|
66
77
|
}
|
|
67
78
|
}]);
|
|
68
79
|
|
|
@@ -21,7 +21,8 @@ export var InlineCard = function InlineCard(_ref) {
|
|
|
21
21
|
renderers = _ref.renderers,
|
|
22
22
|
onResolve = _ref.onResolve,
|
|
23
23
|
testId = _ref.testId,
|
|
24
|
-
inlinePreloaderStyle = _ref.inlinePreloaderStyle
|
|
24
|
+
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
25
|
+
showHoverPreview = _ref.showHoverPreview;
|
|
25
26
|
var status = cardState.status,
|
|
26
27
|
details = cardState.details;
|
|
27
28
|
var cardDetails = details && details.data || getEmptyJsonLd();
|
|
@@ -49,6 +50,7 @@ export var InlineCard = function InlineCard(_ref) {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedProps, {
|
|
53
|
+
showHoverPreview: showHoverPreview,
|
|
52
54
|
link: url,
|
|
53
55
|
isSelected: isSelected,
|
|
54
56
|
onClick: handleFrameClick,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardAppearance, CardPlatform, CardProps } from './types';
|
|
3
3
|
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
export declare const Card: React.ForwardRefExoticComponent<Pick<Pick<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "url" | "
|
|
4
|
+
export declare const Card: React.ForwardRefExoticComponent<Pick<Pick<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "url" | "forwardedRef" | "platform" | "isFrameVisible" | "importer" | "container" | "showActions" | "onResolve" | "embedIframeRef" | "inlinePreloaderStyle" | "ui"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "analyticsContext" | "key" | "url" | "forwardedRef" | "platform" | "isFrameVisible" | "importer" | "container" | "showActions" | "onResolve" | "embedIframeRef" | "inlinePreloaderStyle" | "ui"> & React.RefAttributes<any>>;
|
|
5
5
|
export type { CardAppearance, CardProps, CardPlatform };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ActionName, ElementName, SmartLinkDirection, SmartLinkSize, SmartLinkStatus } from '../../../../constants';
|
|
2
|
+
import { SerializedStyles } from '@emotion/core';
|
|
2
3
|
import { ActionProps } from '../actions/action/types';
|
|
3
4
|
export declare type BlockProps = {
|
|
4
5
|
direction?: SmartLinkDirection;
|
|
5
6
|
size?: SmartLinkSize;
|
|
6
7
|
status?: SmartLinkStatus;
|
|
7
8
|
testId?: string;
|
|
9
|
+
extraCss?: SerializedStyles;
|
|
8
10
|
};
|
|
9
11
|
export declare type ElementItem = {
|
|
10
12
|
name: ElementName;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const HoverCardContainer: import("@emotion/styled-base").StyledComponent<Pick<import("@atlaskit/tooltip").TooltipPrimitiveProps, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate"> & import("react").RefAttributes<HTMLDivElement> & import("react").Attributes, Pick<Pick<import("@atlaskit/tooltip").TooltipPrimitiveProps, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate"> & import("react").RefAttributes<HTMLDivElement> & import("react").Attributes, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate">, any>;
|
|
@@ -19,6 +19,8 @@ export interface InlineCardResolvedViewProps {
|
|
|
19
19
|
titleTextColor?: string;
|
|
20
20
|
/** The Emoji icon prefix that was added to the title text via Add emoji button */
|
|
21
21
|
titlePrefix?: React.ReactNode;
|
|
22
|
+
/** Enables showing a custom preview on hover of link */
|
|
23
|
+
showHoverPreview?: boolean;
|
|
22
24
|
}
|
|
23
25
|
export declare class InlineCardResolvedView extends React.Component<InlineCardResolvedViewProps> {
|
|
24
26
|
renderLozenge(): JSX.Element | null;
|