@atlaskit/smart-card 17.7.7 → 17.7.10
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/constants.js +1 -0
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +2 -2
- package/dist/cjs/utils/analytics/analytics.js +3 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/index.js +2 -2
- package/dist/cjs/view/CardWithUrl/component.js +12 -6
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +3 -1
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +12 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/container/index.js +5 -3
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +3 -1
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +12 -4
- package/dist/cjs/view/FlexibleCard/index.js +8 -3
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/index.js +2 -2
- package/dist/es2019/view/CardWithUrl/component.js +11 -7
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +12 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +3 -1
- package/dist/es2019/view/FlexibleCard/components/container/index.js +5 -3
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +3 -1
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +37 -4
- package/dist/es2019/view/FlexibleCard/index.js +8 -3
- package/dist/esm/constants.js +1 -0
- package/dist/esm/messages.js +5 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +2 -2
- package/dist/esm/utils/analytics/analytics.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/index.js +2 -2
- package/dist/esm/view/CardWithUrl/component.js +13 -7
- package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +11 -0
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +4 -2
- package/dist/esm/view/FlexibleCard/components/container/index.js +5 -3
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +3 -1
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +12 -4
- package/dist/esm/view/FlexibleCard/index.js +8 -3
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +1 -1
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
- package/dist/types/utils/analytics/analytics.d.ts +2 -2
- package/dist/types/view/BlockCard/types.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/actions/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/container/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/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.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e04b58c623e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e04b58c623e) - Add EditAction
|
|
8
|
+
|
|
9
|
+
## 17.7.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`63d4f963f72`](https://bitbucket.org/atlassian/atlassian-frontend/commits/63d4f963f72) - Flexible UI: Set PreviewBlock image aspect ratio to 16:9
|
|
14
|
+
|
|
15
|
+
## 17.7.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`d75ce5b847d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d75ce5b847d) - Add link click analytics to flexible ui title block component
|
|
20
|
+
|
|
3
21
|
## 17.7.7
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/constants.js
CHANGED
|
@@ -156,6 +156,7 @@ exports.ActionName = ActionName;
|
|
|
156
156
|
|
|
157
157
|
(function (ActionName) {
|
|
158
158
|
ActionName["DeleteAction"] = "DeleteAction";
|
|
159
|
+
ActionName["EditAction"] = "EditAction";
|
|
159
160
|
ActionName["CustomAction"] = "CustomAction";
|
|
160
161
|
})(ActionName || (exports.ActionName = ActionName = {}));
|
|
161
162
|
|
package/dist/cjs/messages.js
CHANGED
|
@@ -43,6 +43,11 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
43
43
|
defaultMessage: 'Delete',
|
|
44
44
|
description: 'Allow a user to delete a link'
|
|
45
45
|
},
|
|
46
|
+
edit: {
|
|
47
|
+
id: 'fabric.linking.edit',
|
|
48
|
+
defaultMessage: 'Edit',
|
|
49
|
+
description: 'Allow a user to edit a link'
|
|
50
|
+
},
|
|
46
51
|
modified_by: {
|
|
47
52
|
id: 'fabric.linking.updated_by',
|
|
48
53
|
defaultMessage: 'Modified by {context}',
|
|
@@ -20,8 +20,8 @@ var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
|
20
20
|
authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
|
|
21
21
|
return dispatchAnalytics((0, _analytics.uiAuthAlternateAccountEvent)(display, definitionId, extensionKey));
|
|
22
22
|
},
|
|
23
|
-
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
24
|
-
return dispatchAnalytics((0, _analytics.uiCardClickedEvent)(display, definitionId, extensionKey));
|
|
23
|
+
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
|
|
24
|
+
return dispatchAnalytics((0, _analytics.uiCardClickedEvent)(display, definitionId, extensionKey, isModifierKeyPressed));
|
|
25
25
|
},
|
|
26
26
|
actionClickedEvent: function actionClickedEvent(id, extensionKey, actionType, display, invokeType) {
|
|
27
27
|
(0, _ufoExperiences.startUfoExperience)('smart-link-action-invocation', id, {
|
|
@@ -230,7 +230,7 @@ var uiAuthAlternateAccountEvent = function uiAuthAlternateAccountEvent(display,
|
|
|
230
230
|
|
|
231
231
|
exports.uiAuthAlternateAccountEvent = uiAuthAlternateAccountEvent;
|
|
232
232
|
|
|
233
|
-
var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, extensionKey) {
|
|
233
|
+
var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
|
|
234
234
|
return {
|
|
235
235
|
action: 'clicked',
|
|
236
236
|
actionSubject: 'smartLink',
|
|
@@ -238,7 +238,8 @@ var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, exte
|
|
|
238
238
|
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
239
239
|
definitionId: definitionId || '',
|
|
240
240
|
extensionKey: extensionKey || '',
|
|
241
|
-
display: display
|
|
241
|
+
display: display,
|
|
242
|
+
isModifierKeyPressed: isModifierKeyPressed
|
|
242
243
|
})
|
|
243
244
|
};
|
|
244
245
|
};
|
package/dist/cjs/version.json
CHANGED
|
@@ -104,7 +104,7 @@ var BlockCard = function BlockCard(_ref) {
|
|
|
104
104
|
handleAuthorize = _ref.handleAuthorize,
|
|
105
105
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
106
106
|
handleFrameClick = _ref.handleFrameClick,
|
|
107
|
-
|
|
107
|
+
handleAnalytics = _ref.handleAnalytics,
|
|
108
108
|
handleInvoke = _ref.handleInvoke,
|
|
109
109
|
renderers = _ref.renderers,
|
|
110
110
|
isSelected = _ref.isSelected,
|
|
@@ -115,7 +115,7 @@ var BlockCard = function BlockCard(_ref) {
|
|
|
115
115
|
var data = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
116
116
|
var meta = details && details.meta;
|
|
117
117
|
var extractorOpts = {
|
|
118
|
-
handleAnalytics:
|
|
118
|
+
handleAnalytics: handleAnalytics,
|
|
119
119
|
handleInvoke: handleInvoke,
|
|
120
120
|
extensionKey: (0, _helpers.getExtensionKey)(details)
|
|
121
121
|
};
|
|
@@ -63,7 +63,10 @@ function CardWithUrlContent(_ref) {
|
|
|
63
63
|
var definitionId = (0, _helpers.getDefinitionId)(state.details);
|
|
64
64
|
var extensionKey = (0, _helpers.getExtensionKey)(state.details);
|
|
65
65
|
var resourceType = (0, _helpers.getResourceType)(state.details);
|
|
66
|
-
var services = (0, _helpers.getServices)(state.details);
|
|
66
|
+
var services = (0, _helpers.getServices)(state.details);
|
|
67
|
+
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
68
|
+
return (0, _flexible.isFlexibleUiCard)(children);
|
|
69
|
+
}, [children]); // Setup UI handlers.
|
|
67
70
|
|
|
68
71
|
var handleClick = (0, _react.useCallback)(function (event) {
|
|
69
72
|
var clickUrl = (0, _helpers.getClickUrl)(url, state.details);
|
|
@@ -71,11 +74,12 @@ function CardWithUrlContent(_ref) {
|
|
|
71
74
|
}, [state.details, url]);
|
|
72
75
|
var handleClickWrapper = (0, _react.useCallback)(function (event) {
|
|
73
76
|
if (state.status === 'resolved') {
|
|
74
|
-
|
|
77
|
+
var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
|
|
78
|
+
analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
onClick ? onClick(event) : handleClick(event);
|
|
78
|
-
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick]);
|
|
82
|
+
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
79
83
|
var handleAuthorize = (0, _react.useCallback)(function () {
|
|
80
84
|
return actions.authorize(appearance);
|
|
81
85
|
}, [actions, appearance]);
|
|
@@ -109,13 +113,15 @@ function CardWithUrlContent(_ref) {
|
|
|
109
113
|
throw error;
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
if (
|
|
116
|
+
if (isFlexibleUi) {
|
|
113
117
|
return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
|
|
114
118
|
cardState: state,
|
|
115
119
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
120
|
+
onClick: handleClickWrapper,
|
|
116
121
|
renderers: renderers,
|
|
117
122
|
ui: ui,
|
|
118
|
-
url: url
|
|
123
|
+
url: url,
|
|
124
|
+
testId: testId
|
|
119
125
|
}, children);
|
|
120
126
|
}
|
|
121
127
|
|
|
@@ -143,7 +149,7 @@ function CardWithUrlContent(_ref) {
|
|
|
143
149
|
handleErrorRetry: handleRetry,
|
|
144
150
|
handleInvoke: handleInvoke,
|
|
145
151
|
handleFrameClick: handleClickWrapper,
|
|
146
|
-
|
|
152
|
+
handleAnalytics: dispatchAnalytics,
|
|
147
153
|
isSelected: isSelected,
|
|
148
154
|
onResolve: onResolve,
|
|
149
155
|
testId: testId,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DeleteAction = exports.CustomAction = void 0;
|
|
6
|
+
exports.EditAction = exports.DeleteAction = exports.CustomAction = void 0;
|
|
7
7
|
|
|
8
8
|
var _constants = require("../../../../constants");
|
|
9
9
|
|
|
@@ -16,5 +16,7 @@ var _utils = require("./utils");
|
|
|
16
16
|
// DataActions infer that the action depends on the data from the context.
|
|
17
17
|
var DeleteAction = (0, _utils.createUIAction)(_constants.ActionName.DeleteAction);
|
|
18
18
|
exports.DeleteAction = DeleteAction;
|
|
19
|
+
var EditAction = (0, _utils.createUIAction)(_constants.ActionName.EditAction);
|
|
20
|
+
exports.EditAction = EditAction;
|
|
19
21
|
var CustomAction = (0, _utils.createUIAction)(_constants.ActionName.CustomAction);
|
|
20
22
|
exports.CustomAction = CustomAction;
|
|
@@ -27,6 +27,8 @@ var _messages = require("../../../../messages");
|
|
|
27
27
|
|
|
28
28
|
var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
|
|
29
29
|
|
|
30
|
+
var _edit = _interopRequireDefault(require("@atlaskit/icon/glyph/edit"));
|
|
31
|
+
|
|
30
32
|
var _actionMappings;
|
|
31
33
|
|
|
32
34
|
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); }
|
|
@@ -50,6 +52,16 @@ var actionMappings = (_actionMappings = {}, (0, _defineProperty2.default)(_actio
|
|
|
50
52
|
}),
|
|
51
53
|
toolTipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.delete)
|
|
52
54
|
}
|
|
55
|
+
}), (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.EditAction, {
|
|
56
|
+
component: _action.default,
|
|
57
|
+
props: {
|
|
58
|
+
testId: 'smart-action-edit-action',
|
|
59
|
+
content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.edit),
|
|
60
|
+
icon: /*#__PURE__*/_react.default.createElement(_edit.default, {
|
|
61
|
+
label: "Edit"
|
|
62
|
+
}),
|
|
63
|
+
toolTipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.edit)
|
|
64
|
+
}
|
|
53
65
|
}), _actionMappings);
|
|
54
66
|
|
|
55
67
|
var getContextKey = function getContextKey(name) {
|
|
@@ -33,7 +33,7 @@ var _utils = require("../../utils");
|
|
|
33
33
|
|
|
34
34
|
var _actionGroup = _interopRequireDefault(require("../../action-group"));
|
|
35
35
|
|
|
36
|
-
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text", "showActionOnHover"];
|
|
36
|
+
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "onClick", "text", "showActionOnHover"];
|
|
37
37
|
|
|
38
38
|
var _templateObject;
|
|
39
39
|
|
|
@@ -54,6 +54,7 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
54
54
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
55
55
|
testId = _ref.testId,
|
|
56
56
|
theme = _ref.theme,
|
|
57
|
+
onClick = _ref.onClick,
|
|
57
58
|
text = _ref.text,
|
|
58
59
|
showActionOnHover = _ref.showActionOnHover,
|
|
59
60
|
blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
@@ -79,7 +80,8 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
79
80
|
width: _constants.SmartLinkWidth.Flexible
|
|
80
81
|
}, (0, _core.jsx)(_elements.Title, (0, _extends2.default)({
|
|
81
82
|
maxLines: maxLines,
|
|
82
|
-
theme: theme
|
|
83
|
+
theme: theme,
|
|
84
|
+
onClick: onClick
|
|
83
85
|
}, overrideText)), subtitleElements && (0, _core.jsx)(_elementGroup.default, {
|
|
84
86
|
direction: _constants.SmartLinkDirection.Horizontal
|
|
85
87
|
}, subtitleElements)), metadataElements && (0, _core.jsx)(_elementGroup.default, {
|
|
@@ -63,11 +63,12 @@ var getContainerStyles = function getContainerStyles(size, hideBackground, hideE
|
|
|
63
63
|
|
|
64
64
|
exports.getContainerStyles = getContainerStyles;
|
|
65
65
|
|
|
66
|
-
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry) {
|
|
66
|
+
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick) {
|
|
67
67
|
return _react.default.Children.map(children, function (child) {
|
|
68
68
|
if ( /*#__PURE__*/_react.default.isValidElement(child) && (0, _flexible.isFlexibleUiBlock)(child)) {
|
|
69
69
|
var blockSize = child.props.size;
|
|
70
70
|
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
71
|
+
onClick: onClick,
|
|
71
72
|
retry: (0, _flexible.isFlexibleUiTitleBlock)(child) ? retry : undefined,
|
|
72
73
|
size: blockSize || containerSize,
|
|
73
74
|
status: status,
|
|
@@ -92,12 +93,13 @@ var Container = function Container(_ref) {
|
|
|
92
93
|
_ref$testId = _ref.testId,
|
|
93
94
|
testId = _ref$testId === void 0 ? 'smart-links-container' : _ref$testId,
|
|
94
95
|
_ref$theme = _ref.theme,
|
|
95
|
-
theme = _ref$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref$theme
|
|
96
|
+
theme = _ref$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref$theme,
|
|
97
|
+
onClick = _ref.onClick;
|
|
96
98
|
return (0, _core.jsx)("div", {
|
|
97
99
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding),
|
|
98
100
|
"data-smart-link-container": true,
|
|
99
101
|
"data-testid": testId
|
|
100
|
-
}, renderChildren(children, size, theme, status, retry));
|
|
102
|
+
}, renderChildren(children, size, theme, status, retry, onClick));
|
|
101
103
|
};
|
|
102
104
|
|
|
103
105
|
var _default = Container;
|
|
@@ -66,7 +66,8 @@ var Link = function Link(_ref) {
|
|
|
66
66
|
text = _ref.text,
|
|
67
67
|
_ref$theme = _ref.theme,
|
|
68
68
|
theme = _ref$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref$theme,
|
|
69
|
-
url = _ref.url
|
|
69
|
+
url = _ref.url,
|
|
70
|
+
onClick = _ref.onClick;
|
|
70
71
|
return (0, _core.jsx)("span", {
|
|
71
72
|
css: containerStyles
|
|
72
73
|
}, (0, _core.jsx)(_tooltip.default, {
|
|
@@ -77,6 +78,7 @@ var Link = function Link(_ref) {
|
|
|
77
78
|
css: getAnchorStyles(size, theme, getMaxLines(maxLines)),
|
|
78
79
|
"data-smart-element-link": true,
|
|
79
80
|
"data-testid": testId,
|
|
81
|
+
onClick: onClick,
|
|
80
82
|
href: url
|
|
81
83
|
}, text)));
|
|
82
84
|
};
|
|
@@ -17,9 +17,17 @@ var _imageIcon = _interopRequireDefault(require("../../common/image-icon"));
|
|
|
17
17
|
|
|
18
18
|
var _templateObject;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Media: Image
|
|
22
|
+
* [aspect-ratio: 16 / 9] The context box is fixed to aspect ratio of 16:9.
|
|
23
|
+
* [object-fit: cover] The replaced content is sized to maintain
|
|
24
|
+
* its aspect ratio while filling the element's entire content box.
|
|
25
|
+
* If the object's aspect ratio does not match the aspect ratio of its box,
|
|
26
|
+
* then the object will be clipped to fit.
|
|
27
|
+
* [object-position] Center alignment of the selected replaced element's
|
|
28
|
+
* contents within the element's box.
|
|
29
|
+
*/
|
|
30
|
+
var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
|
|
23
31
|
|
|
24
32
|
var Media = function Media(_ref) {
|
|
25
33
|
var _ref$testId = _ref.testId,
|
|
@@ -32,7 +40,7 @@ var Media = function Media(_ref) {
|
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
return (0, _core.jsx)("div", {
|
|
35
|
-
css: styles
|
|
43
|
+
css: styles,
|
|
36
44
|
"data-smart-element-media": true,
|
|
37
45
|
"data-testid": testId
|
|
38
46
|
}, (0, _core.jsx)(_imageIcon.default, {
|
|
@@ -23,7 +23,9 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
23
23
|
onAuthorize = _ref.onAuthorize,
|
|
24
24
|
renderers = _ref.renderers,
|
|
25
25
|
ui = _ref.ui,
|
|
26
|
-
url = _ref.url
|
|
26
|
+
url = _ref.url,
|
|
27
|
+
onClick = _ref.onClick,
|
|
28
|
+
testId = _ref.testId;
|
|
27
29
|
var cardType = cardState.status,
|
|
28
30
|
details = cardState.details;
|
|
29
31
|
var status = cardType;
|
|
@@ -31,9 +33,12 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
31
33
|
var retry = (0, _utils.getRetryOptions)(url, status, details, onAuthorize);
|
|
32
34
|
return /*#__PURE__*/_react.default.createElement(_flexibleUiContext.FlexibleUiContext.Provider, {
|
|
33
35
|
value: context
|
|
34
|
-
}, /*#__PURE__*/_react.default.createElement(_container.default, (0, _extends2.default)({
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement(_container.default, (0, _extends2.default)({
|
|
37
|
+
testId: testId
|
|
38
|
+
}, ui, {
|
|
35
39
|
retry: retry,
|
|
36
|
-
status: status
|
|
40
|
+
status: status,
|
|
41
|
+
onClick: onClick
|
|
37
42
|
}), children));
|
|
38
43
|
};
|
|
39
44
|
|
package/dist/es2019/constants.js
CHANGED
package/dist/es2019/messages.js
CHANGED
|
@@ -35,6 +35,11 @@ export const messages = defineMessages({
|
|
|
35
35
|
defaultMessage: 'Delete',
|
|
36
36
|
description: 'Allow a user to delete a link'
|
|
37
37
|
},
|
|
38
|
+
edit: {
|
|
39
|
+
id: 'fabric.linking.edit',
|
|
40
|
+
defaultMessage: 'Edit',
|
|
41
|
+
description: 'Allow a user to edit a link'
|
|
42
|
+
},
|
|
38
43
|
modified_by: {
|
|
39
44
|
id: 'fabric.linking.updated_by',
|
|
40
45
|
defaultMessage: 'Modified by {context}',
|
|
@@ -5,7 +5,7 @@ export const useSmartLinkAnalytics = dispatchAnalytics => {
|
|
|
5
5
|
const ui = useMemo(() => ({
|
|
6
6
|
authEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey)),
|
|
7
7
|
authAlternateAccountEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey)),
|
|
8
|
-
cardClickedEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey)),
|
|
8
|
+
cardClickedEvent: (display, definitionId, extensionKey, isModifierKeyPressed) => dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed)),
|
|
9
9
|
actionClickedEvent: (id, extensionKey, actionType, display, invokeType) => {
|
|
10
10
|
startUfoExperience('smart-link-action-invocation', id, {
|
|
11
11
|
actionType,
|
|
@@ -169,14 +169,15 @@ export const uiAuthAlternateAccountEvent = (display, definitionId, extensionKey)
|
|
|
169
169
|
display
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
|
-
export const uiCardClickedEvent = (display, definitionId, extensionKey) => ({
|
|
172
|
+
export const uiCardClickedEvent = (display, definitionId, extensionKey, isModifierKeyPressed) => ({
|
|
173
173
|
action: 'clicked',
|
|
174
174
|
actionSubject: 'smartLink',
|
|
175
175
|
eventType: 'ui',
|
|
176
176
|
attributes: { ...context,
|
|
177
177
|
definitionId: definitionId || '',
|
|
178
178
|
extensionKey: extensionKey || '',
|
|
179
|
-
display
|
|
179
|
+
display,
|
|
180
|
+
isModifierKeyPressed
|
|
180
181
|
}
|
|
181
182
|
});
|
|
182
183
|
export const uiActionClickedEvent = (extensionKey, actionType, display) => ({
|
package/dist/es2019/version.json
CHANGED
|
@@ -25,7 +25,7 @@ export const BlockCard = ({
|
|
|
25
25
|
handleAuthorize,
|
|
26
26
|
handleErrorRetry,
|
|
27
27
|
handleFrameClick,
|
|
28
|
-
|
|
28
|
+
handleAnalytics,
|
|
29
29
|
handleInvoke,
|
|
30
30
|
renderers,
|
|
31
31
|
isSelected,
|
|
@@ -39,7 +39,7 @@ export const BlockCard = ({
|
|
|
39
39
|
const data = details && details.data || getEmptyJsonLd();
|
|
40
40
|
const meta = details && details.meta;
|
|
41
41
|
const extractorOpts = {
|
|
42
|
-
handleAnalytics
|
|
42
|
+
handleAnalytics,
|
|
43
43
|
handleInvoke,
|
|
44
44
|
extensionKey: getExtensionKey(details)
|
|
45
45
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useCallback } from 'react';
|
|
1
|
+
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { isSpecialEvent } from '../../utils';
|
|
3
3
|
import * as measure from '../../utils/performance';
|
|
4
4
|
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey } from '../../state/helpers';
|
|
@@ -38,7 +38,8 @@ export function CardWithUrlContent({
|
|
|
38
38
|
const definitionId = getDefinitionId(state.details);
|
|
39
39
|
const extensionKey = getExtensionKey(state.details);
|
|
40
40
|
const resourceType = getResourceType(state.details);
|
|
41
|
-
const services = getServices(state.details);
|
|
41
|
+
const services = getServices(state.details);
|
|
42
|
+
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]); // Setup UI handlers.
|
|
42
43
|
|
|
43
44
|
const handleClick = useCallback(event => {
|
|
44
45
|
const clickUrl = getClickUrl(url, state.details);
|
|
@@ -46,11 +47,12 @@ export function CardWithUrlContent({
|
|
|
46
47
|
}, [state.details, url]);
|
|
47
48
|
const handleClickWrapper = useCallback(event => {
|
|
48
49
|
if (state.status === 'resolved') {
|
|
49
|
-
|
|
50
|
+
const isModifierKeyPressed = isSpecialEvent(event);
|
|
51
|
+
analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
onClick ? onClick(event) : handleClick(event);
|
|
53
|
-
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick]);
|
|
55
|
+
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
54
56
|
const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
|
|
55
57
|
const handleRetry = useCallback(() => {
|
|
56
58
|
actions.reload();
|
|
@@ -80,13 +82,15 @@ export function CardWithUrlContent({
|
|
|
80
82
|
throw error;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
if (
|
|
85
|
+
if (isFlexibleUi) {
|
|
84
86
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
85
87
|
cardState: state,
|
|
86
88
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
89
|
+
onClick: handleClickWrapper,
|
|
87
90
|
renderers: renderers,
|
|
88
91
|
ui: ui,
|
|
89
|
-
url: url
|
|
92
|
+
url: url,
|
|
93
|
+
testId: testId
|
|
90
94
|
}, children);
|
|
91
95
|
}
|
|
92
96
|
|
|
@@ -114,7 +118,7 @@ export function CardWithUrlContent({
|
|
|
114
118
|
handleErrorRetry: handleRetry,
|
|
115
119
|
handleInvoke: handleInvoke,
|
|
116
120
|
handleFrameClick: handleClickWrapper,
|
|
117
|
-
|
|
121
|
+
handleAnalytics: dispatchAnalytics,
|
|
118
122
|
isSelected: isSelected,
|
|
119
123
|
onResolve: onResolve,
|
|
120
124
|
testId: testId,
|
|
@@ -6,4 +6,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
|
|
|
6
6
|
// DataActions infer that the action depends on the data from the context.
|
|
7
7
|
|
|
8
8
|
export const DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
9
|
+
export const EditAction = createUIAction(ActionName.EditAction);
|
|
9
10
|
export const CustomAction = createUIAction(ActionName.CustomAction);
|
|
@@ -6,6 +6,7 @@ import Action from './action';
|
|
|
6
6
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
7
|
import { messages } from '../../../../messages';
|
|
8
8
|
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
9
|
+
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
9
10
|
const actionMappings = {
|
|
10
11
|
[ActionName.CustomAction]: {
|
|
11
12
|
component: Action,
|
|
@@ -21,6 +22,17 @@ const actionMappings = {
|
|
|
21
22
|
}),
|
|
22
23
|
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
|
|
23
24
|
}
|
|
25
|
+
},
|
|
26
|
+
[ActionName.EditAction]: {
|
|
27
|
+
component: Action,
|
|
28
|
+
props: {
|
|
29
|
+
testId: 'smart-action-edit-action',
|
|
30
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit),
|
|
31
|
+
icon: /*#__PURE__*/React.createElement(EditIcon, {
|
|
32
|
+
label: "Edit"
|
|
33
|
+
}),
|
|
34
|
+
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
|
|
35
|
+
}
|
|
24
36
|
}
|
|
25
37
|
};
|
|
26
38
|
|
|
@@ -29,6 +29,7 @@ const TitleBlockResolvedView = ({
|
|
|
29
29
|
actions = [],
|
|
30
30
|
testId,
|
|
31
31
|
theme,
|
|
32
|
+
onClick,
|
|
32
33
|
text,
|
|
33
34
|
showActionOnHover,
|
|
34
35
|
...blockProps
|
|
@@ -50,7 +51,8 @@ const TitleBlockResolvedView = ({
|
|
|
50
51
|
width: SmartLinkWidth.Flexible
|
|
51
52
|
}, jsx(Title, _extends({
|
|
52
53
|
maxLines: maxLines,
|
|
53
|
-
theme: theme
|
|
54
|
+
theme: theme,
|
|
55
|
+
onClick: onClick
|
|
54
56
|
}, overrideText)), subtitleElements && jsx(ElementGroup, {
|
|
55
57
|
direction: SmartLinkDirection.Horizontal
|
|
56
58
|
}, subtitleElements)), metadataElements && jsx(ElementGroup, {
|
|
@@ -56,12 +56,13 @@ export const getContainerStyles = (size, hideBackground, hideElevation, hidePadd
|
|
|
56
56
|
${hideElevation ? '' : elevationStyles}
|
|
57
57
|
`;
|
|
58
58
|
|
|
59
|
-
const renderChildren = (children, containerSize, containerTheme, status, retry) => React.Children.map(children, child => {
|
|
59
|
+
const renderChildren = (children, containerSize, containerTheme, status, retry, onClick) => React.Children.map(children, child => {
|
|
60
60
|
if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
|
|
61
61
|
const {
|
|
62
62
|
size: blockSize
|
|
63
63
|
} = child.props;
|
|
64
64
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
65
|
+
onClick,
|
|
65
66
|
retry: isFlexibleUiTitleBlock(child) ? retry : undefined,
|
|
66
67
|
size: blockSize || containerSize,
|
|
67
68
|
status,
|
|
@@ -79,11 +80,12 @@ const Container = ({
|
|
|
79
80
|
size = SmartLinkSize.Medium,
|
|
80
81
|
status,
|
|
81
82
|
testId = 'smart-links-container',
|
|
82
|
-
theme = SmartLinkTheme.Link
|
|
83
|
+
theme = SmartLinkTheme.Link,
|
|
84
|
+
onClick
|
|
83
85
|
}) => jsx("div", {
|
|
84
86
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding),
|
|
85
87
|
"data-smart-link-container": true,
|
|
86
88
|
"data-testid": testId
|
|
87
|
-
}, renderChildren(children, size, theme, status, retry));
|
|
89
|
+
}, renderChildren(children, size, theme, status, retry, onClick));
|
|
88
90
|
|
|
89
91
|
export default Container;
|
|
@@ -70,7 +70,8 @@ const Link = ({
|
|
|
70
70
|
testId = 'smart-element-link',
|
|
71
71
|
text,
|
|
72
72
|
theme = SmartLinkTheme.Link,
|
|
73
|
-
url
|
|
73
|
+
url,
|
|
74
|
+
onClick
|
|
74
75
|
}) => jsx("span", {
|
|
75
76
|
css: containerStyles
|
|
76
77
|
}, jsx(Tooltip, {
|
|
@@ -81,6 +82,7 @@ const Link = ({
|
|
|
81
82
|
css: getAnchorStyles(size, theme, getMaxLines(maxLines)),
|
|
82
83
|
"data-smart-element-link": true,
|
|
83
84
|
"data-testid": testId,
|
|
85
|
+
onClick: onClick,
|
|
84
86
|
href: url
|
|
85
87
|
}, text)));
|
|
86
88
|
|
|
@@ -3,13 +3,46 @@ import React from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import ImageIcon from '../../common/image-icon';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Media: Image
|
|
8
|
+
* [aspect-ratio: 16 / 9] The context box is fixed to aspect ratio of 16:9.
|
|
9
|
+
* [object-fit: cover] The replaced content is sized to maintain
|
|
10
|
+
* its aspect ratio while filling the element's entire content box.
|
|
11
|
+
* If the object's aspect ratio does not match the aspect ratio of its box,
|
|
12
|
+
* then the object will be clipped to fit.
|
|
13
|
+
* [object-position] Center alignment of the selected replaced element's
|
|
14
|
+
* contents within the element's box.
|
|
15
|
+
*/
|
|
16
|
+
const styles = css`
|
|
17
|
+
aspect-ratio: 16 / 9;
|
|
7
18
|
display: flex;
|
|
8
|
-
justify-content: center;
|
|
9
19
|
width: 100%;
|
|
20
|
+
|
|
21
|
+
// fallback
|
|
22
|
+
@supports not (aspect-ratio: auto) {
|
|
23
|
+
padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)
|
|
24
|
+
height: 0;
|
|
25
|
+
position: relative;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
10
29
|
> img {
|
|
11
|
-
|
|
30
|
+
min-height: 100%;
|
|
31
|
+
min-width: 100%;
|
|
12
32
|
max-height: 100%;
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
object-fit: cover;
|
|
35
|
+
object-position: center center;
|
|
36
|
+
|
|
37
|
+
// fallback
|
|
38
|
+
@supports not (aspect-ratio: auto) {
|
|
39
|
+
position: absolute;
|
|
40
|
+
transform: translate(-50%, -50%);
|
|
41
|
+
left: 50%;
|
|
42
|
+
top: 50%;
|
|
43
|
+
width: auto;
|
|
44
|
+
height: auto;
|
|
45
|
+
}
|
|
13
46
|
}
|
|
14
47
|
`;
|
|
15
48
|
|
|
@@ -23,7 +56,7 @@ const Media = ({
|
|
|
23
56
|
}
|
|
24
57
|
|
|
25
58
|
return jsx("div", {
|
|
26
|
-
css: styles
|
|
59
|
+
css: styles,
|
|
27
60
|
"data-smart-element-media": true,
|
|
28
61
|
"data-testid": testId
|
|
29
62
|
}, jsx(ImageIcon, {
|
|
@@ -10,7 +10,9 @@ const FlexibleCard = ({
|
|
|
10
10
|
onAuthorize,
|
|
11
11
|
renderers,
|
|
12
12
|
ui,
|
|
13
|
-
url
|
|
13
|
+
url,
|
|
14
|
+
onClick,
|
|
15
|
+
testId
|
|
14
16
|
}) => {
|
|
15
17
|
const {
|
|
16
18
|
status: cardType,
|
|
@@ -21,9 +23,12 @@ const FlexibleCard = ({
|
|
|
21
23
|
const retry = getRetryOptions(url, status, details, onAuthorize);
|
|
22
24
|
return /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
23
25
|
value: context
|
|
24
|
-
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
27
|
+
testId: testId
|
|
28
|
+
}, ui, {
|
|
25
29
|
retry: retry,
|
|
26
|
-
status: status
|
|
30
|
+
status: status,
|
|
31
|
+
onClick: onClick
|
|
27
32
|
}), children));
|
|
28
33
|
};
|
|
29
34
|
|
package/dist/esm/constants.js
CHANGED
package/dist/esm/messages.js
CHANGED
|
@@ -35,6 +35,11 @@ export var messages = defineMessages({
|
|
|
35
35
|
defaultMessage: 'Delete',
|
|
36
36
|
description: 'Allow a user to delete a link'
|
|
37
37
|
},
|
|
38
|
+
edit: {
|
|
39
|
+
id: 'fabric.linking.edit',
|
|
40
|
+
defaultMessage: 'Edit',
|
|
41
|
+
description: 'Allow a user to edit a link'
|
|
42
|
+
},
|
|
38
43
|
modified_by: {
|
|
39
44
|
id: 'fabric.linking.updated_by',
|
|
40
45
|
defaultMessage: 'Modified by {context}',
|
|
@@ -10,8 +10,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
10
10
|
authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
|
|
11
11
|
return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
|
|
12
12
|
},
|
|
13
|
-
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
14
|
-
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey));
|
|
13
|
+
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
|
|
14
|
+
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed));
|
|
15
15
|
},
|
|
16
16
|
actionClickedEvent: function actionClickedEvent(id, extensionKey, actionType, display, invokeType) {
|
|
17
17
|
startUfoExperience('smart-link-action-invocation', id, {
|
|
@@ -182,7 +182,7 @@ export var uiAuthAlternateAccountEvent = function uiAuthAlternateAccountEvent(di
|
|
|
182
182
|
})
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
|
-
export var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, extensionKey) {
|
|
185
|
+
export var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
|
|
186
186
|
return {
|
|
187
187
|
action: 'clicked',
|
|
188
188
|
actionSubject: 'smartLink',
|
|
@@ -190,7 +190,8 @@ export var uiCardClickedEvent = function uiCardClickedEvent(display, definitionI
|
|
|
190
190
|
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
191
191
|
definitionId: definitionId || '',
|
|
192
192
|
extensionKey: extensionKey || '',
|
|
193
|
-
display: display
|
|
193
|
+
display: display,
|
|
194
|
+
isModifierKeyPressed: isModifierKeyPressed
|
|
194
195
|
})
|
|
195
196
|
};
|
|
196
197
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -26,7 +26,7 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
26
26
|
handleAuthorize = _ref.handleAuthorize,
|
|
27
27
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
28
28
|
handleFrameClick = _ref.handleFrameClick,
|
|
29
|
-
|
|
29
|
+
handleAnalytics = _ref.handleAnalytics,
|
|
30
30
|
handleInvoke = _ref.handleInvoke,
|
|
31
31
|
renderers = _ref.renderers,
|
|
32
32
|
isSelected = _ref.isSelected,
|
|
@@ -37,7 +37,7 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
37
37
|
var data = details && details.data || getEmptyJsonLd();
|
|
38
38
|
var meta = details && details.meta;
|
|
39
39
|
var extractorOpts = {
|
|
40
|
-
handleAnalytics:
|
|
40
|
+
handleAnalytics: handleAnalytics,
|
|
41
41
|
handleInvoke: handleInvoke,
|
|
42
42
|
extensionKey: getExtensionKey(details)
|
|
43
43
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useCallback } from 'react';
|
|
1
|
+
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { isSpecialEvent } from '../../utils';
|
|
3
3
|
import * as measure from '../../utils/performance';
|
|
4
4
|
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey } from '../../state/helpers';
|
|
@@ -38,7 +38,10 @@ export function CardWithUrlContent(_ref) {
|
|
|
38
38
|
var definitionId = getDefinitionId(state.details);
|
|
39
39
|
var extensionKey = getExtensionKey(state.details);
|
|
40
40
|
var resourceType = getResourceType(state.details);
|
|
41
|
-
var services = getServices(state.details);
|
|
41
|
+
var services = getServices(state.details);
|
|
42
|
+
var isFlexibleUi = useMemo(function () {
|
|
43
|
+
return isFlexibleUiCard(children);
|
|
44
|
+
}, [children]); // Setup UI handlers.
|
|
42
45
|
|
|
43
46
|
var handleClick = useCallback(function (event) {
|
|
44
47
|
var clickUrl = getClickUrl(url, state.details);
|
|
@@ -46,11 +49,12 @@ export function CardWithUrlContent(_ref) {
|
|
|
46
49
|
}, [state.details, url]);
|
|
47
50
|
var handleClickWrapper = useCallback(function (event) {
|
|
48
51
|
if (state.status === 'resolved') {
|
|
49
|
-
|
|
52
|
+
var isModifierKeyPressed = isSpecialEvent(event);
|
|
53
|
+
analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
onClick ? onClick(event) : handleClick(event);
|
|
53
|
-
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick]);
|
|
57
|
+
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
54
58
|
var handleAuthorize = useCallback(function () {
|
|
55
59
|
return actions.authorize(appearance);
|
|
56
60
|
}, [actions, appearance]);
|
|
@@ -84,13 +88,15 @@ export function CardWithUrlContent(_ref) {
|
|
|
84
88
|
throw error;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
if (
|
|
91
|
+
if (isFlexibleUi) {
|
|
88
92
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
89
93
|
cardState: state,
|
|
90
94
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
95
|
+
onClick: handleClickWrapper,
|
|
91
96
|
renderers: renderers,
|
|
92
97
|
ui: ui,
|
|
93
|
-
url: url
|
|
98
|
+
url: url,
|
|
99
|
+
testId: testId
|
|
94
100
|
}, children);
|
|
95
101
|
}
|
|
96
102
|
|
|
@@ -118,7 +124,7 @@ export function CardWithUrlContent(_ref) {
|
|
|
118
124
|
handleErrorRetry: handleRetry,
|
|
119
125
|
handleInvoke: handleInvoke,
|
|
120
126
|
handleFrameClick: handleClickWrapper,
|
|
121
|
-
|
|
127
|
+
handleAnalytics: dispatchAnalytics,
|
|
122
128
|
isSelected: isSelected,
|
|
123
129
|
onResolve: onResolve,
|
|
124
130
|
testId: testId,
|
|
@@ -6,4 +6,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
|
|
|
6
6
|
// DataActions infer that the action depends on the data from the context.
|
|
7
7
|
|
|
8
8
|
export var DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
9
|
+
export var EditAction = createUIAction(ActionName.EditAction);
|
|
9
10
|
export var CustomAction = createUIAction(ActionName.CustomAction);
|
|
@@ -14,6 +14,7 @@ import Action from './action';
|
|
|
14
14
|
import { FormattedMessage } from 'react-intl-next';
|
|
15
15
|
import { messages } from '../../../../messages';
|
|
16
16
|
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
17
|
+
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
17
18
|
var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
|
|
18
19
|
component: Action,
|
|
19
20
|
props: {}
|
|
@@ -27,6 +28,16 @@ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, Act
|
|
|
27
28
|
}),
|
|
28
29
|
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
|
|
29
30
|
}
|
|
31
|
+
}), _defineProperty(_actionMappings, ActionName.EditAction, {
|
|
32
|
+
component: Action,
|
|
33
|
+
props: {
|
|
34
|
+
testId: 'smart-action-edit-action',
|
|
35
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit),
|
|
36
|
+
icon: /*#__PURE__*/React.createElement(EditIcon, {
|
|
37
|
+
label: "Edit"
|
|
38
|
+
}),
|
|
39
|
+
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
|
|
40
|
+
}
|
|
30
41
|
}), _actionMappings);
|
|
31
42
|
|
|
32
43
|
var getContextKey = function getContextKey(name) {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
|
-
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text", "showActionOnHover"];
|
|
5
|
+
var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "onClick", "text", "showActionOnHover"];
|
|
6
6
|
|
|
7
7
|
var _templateObject;
|
|
8
8
|
|
|
@@ -28,6 +28,7 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
28
28
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
29
29
|
testId = _ref.testId,
|
|
30
30
|
theme = _ref.theme,
|
|
31
|
+
onClick = _ref.onClick,
|
|
31
32
|
text = _ref.text,
|
|
32
33
|
showActionOnHover = _ref.showActionOnHover,
|
|
33
34
|
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -53,7 +54,8 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
|
|
|
53
54
|
width: SmartLinkWidth.Flexible
|
|
54
55
|
}, jsx(Title, _extends({
|
|
55
56
|
maxLines: maxLines,
|
|
56
|
-
theme: theme
|
|
57
|
+
theme: theme,
|
|
58
|
+
onClick: onClick
|
|
57
59
|
}, overrideText)), subtitleElements && jsx(ElementGroup, {
|
|
58
60
|
direction: SmartLinkDirection.Horizontal
|
|
59
61
|
}, subtitleElements)), metadataElements && jsx(ElementGroup, {
|
|
@@ -48,11 +48,12 @@ export var getContainerStyles = function getContainerStyles(size, hideBackground
|
|
|
48
48
|
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", " 0;\n flex-direction: column;\n min-width: 0;\n overflow: hidden;\n ", "\n ", "\n ", "\n"])), getGap(size), hideBackground ? '' : "background-color: ".concat(tokens.background, ";"), hidePadding ? '' : "padding: ".concat(getPadding(size), ";"), hideElevation ? '' : elevationStyles);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry) {
|
|
51
|
+
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick) {
|
|
52
52
|
return React.Children.map(children, function (child) {
|
|
53
53
|
if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
|
|
54
54
|
var blockSize = child.props.size;
|
|
55
55
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
56
|
+
onClick: onClick,
|
|
56
57
|
retry: isFlexibleUiTitleBlock(child) ? retry : undefined,
|
|
57
58
|
size: blockSize || containerSize,
|
|
58
59
|
status: status,
|
|
@@ -77,12 +78,13 @@ var Container = function Container(_ref) {
|
|
|
77
78
|
_ref$testId = _ref.testId,
|
|
78
79
|
testId = _ref$testId === void 0 ? 'smart-links-container' : _ref$testId,
|
|
79
80
|
_ref$theme = _ref.theme,
|
|
80
|
-
theme = _ref$theme === void 0 ? SmartLinkTheme.Link : _ref$theme
|
|
81
|
+
theme = _ref$theme === void 0 ? SmartLinkTheme.Link : _ref$theme,
|
|
82
|
+
onClick = _ref.onClick;
|
|
81
83
|
return jsx("div", {
|
|
82
84
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding),
|
|
83
85
|
"data-smart-link-container": true,
|
|
84
86
|
"data-testid": testId
|
|
85
|
-
}, renderChildren(children, size, theme, status, retry));
|
|
87
|
+
}, renderChildren(children, size, theme, status, retry, onClick));
|
|
86
88
|
};
|
|
87
89
|
|
|
88
90
|
export default Container;
|
|
@@ -52,7 +52,8 @@ var Link = function Link(_ref) {
|
|
|
52
52
|
text = _ref.text,
|
|
53
53
|
_ref$theme = _ref.theme,
|
|
54
54
|
theme = _ref$theme === void 0 ? SmartLinkTheme.Link : _ref$theme,
|
|
55
|
-
url = _ref.url
|
|
55
|
+
url = _ref.url,
|
|
56
|
+
onClick = _ref.onClick;
|
|
56
57
|
return jsx("span", {
|
|
57
58
|
css: containerStyles
|
|
58
59
|
}, jsx(Tooltip, {
|
|
@@ -63,6 +64,7 @@ var Link = function Link(_ref) {
|
|
|
63
64
|
css: getAnchorStyles(size, theme, getMaxLines(maxLines)),
|
|
64
65
|
"data-smart-element-link": true,
|
|
65
66
|
"data-testid": testId,
|
|
67
|
+
onClick: onClick,
|
|
66
68
|
href: url
|
|
67
69
|
}, text)));
|
|
68
70
|
};
|
|
@@ -7,9 +7,17 @@ import React from 'react';
|
|
|
7
7
|
import { css, jsx } from '@emotion/core';
|
|
8
8
|
import ImageIcon from '../../common/image-icon';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Media: Image
|
|
12
|
+
* [aspect-ratio: 16 / 9] The context box is fixed to aspect ratio of 16:9.
|
|
13
|
+
* [object-fit: cover] The replaced content is sized to maintain
|
|
14
|
+
* its aspect ratio while filling the element's entire content box.
|
|
15
|
+
* If the object's aspect ratio does not match the aspect ratio of its box,
|
|
16
|
+
* then the object will be clipped to fit.
|
|
17
|
+
* [object-position] Center alignment of the selected replaced element's
|
|
18
|
+
* contents within the element's box.
|
|
19
|
+
*/
|
|
20
|
+
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
|
|
13
21
|
|
|
14
22
|
var Media = function Media(_ref) {
|
|
15
23
|
var _ref$testId = _ref.testId,
|
|
@@ -22,7 +30,7 @@ var Media = function Media(_ref) {
|
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
return jsx("div", {
|
|
25
|
-
css: styles
|
|
33
|
+
css: styles,
|
|
26
34
|
"data-smart-element-media": true,
|
|
27
35
|
"data-testid": testId
|
|
28
36
|
}, jsx(ImageIcon, {
|
|
@@ -10,7 +10,9 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
10
10
|
onAuthorize = _ref.onAuthorize,
|
|
11
11
|
renderers = _ref.renderers,
|
|
12
12
|
ui = _ref.ui,
|
|
13
|
-
url = _ref.url
|
|
13
|
+
url = _ref.url,
|
|
14
|
+
onClick = _ref.onClick,
|
|
15
|
+
testId = _ref.testId;
|
|
14
16
|
var cardType = cardState.status,
|
|
15
17
|
details = cardState.details;
|
|
16
18
|
var status = cardType;
|
|
@@ -18,9 +20,12 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
18
20
|
var retry = getRetryOptions(url, status, details, onAuthorize);
|
|
19
21
|
return /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
20
22
|
value: context
|
|
21
|
-
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
24
|
+
testId: testId
|
|
25
|
+
}, ui, {
|
|
22
26
|
retry: retry,
|
|
23
|
-
status: status
|
|
27
|
+
status: status,
|
|
28
|
+
onClick: onClick
|
|
24
29
|
}), children));
|
|
25
30
|
};
|
|
26
31
|
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageDescriptor } from 'react-intl-next';
|
|
2
|
-
export declare type MessageKey = 'cannot_find_link' | 'click_to_join' | 'connect_link_account' | 'created_by' | 'created_on' | 'delete' | 'modified_by' | 'modified_on' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access' | 'request_denied';
|
|
2
|
+
export declare type MessageKey = 'cannot_find_link' | 'click_to_join' | 'connect_link_account' | 'created_by' | 'created_on' | 'delete' | 'edit' | 'modified_by' | 'modified_on' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access' | 'request_denied';
|
|
3
3
|
declare type Messages = {
|
|
4
4
|
[K in MessageKey]: MessageDescriptor;
|
|
5
5
|
};
|
|
@@ -7,7 +7,7 @@ export declare const useSmartLinkAnalytics: (dispatchAnalytics: AnalyticsHandler
|
|
|
7
7
|
ui: {
|
|
8
8
|
authEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
9
9
|
authAlternateAccountEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
10
|
-
cardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
10
|
+
cardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined, isModifierKeyPressed?: boolean | undefined) => void;
|
|
11
11
|
actionClickedEvent: (id: string, extensionKey: string, actionType: string, display: CardInnerAppearance, invokeType: InvokeType) => void;
|
|
12
12
|
closedAuthEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
13
13
|
renderSuccessEvent: (display: CardInnerAppearance, id: string, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
@@ -12,7 +12,7 @@ export declare function useSmartLink(id: string, url: string, dispatchAnalytics:
|
|
|
12
12
|
ui: {
|
|
13
13
|
authEvent: (display: import("../../view/Card/types").CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
14
14
|
authAlternateAccountEvent: (display: import("../../view/Card/types").CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
15
|
-
cardClickedEvent: (display: import("../../view/Card/types").CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
15
|
+
cardClickedEvent: (display: import("../../view/Card/types").CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined, isModifierKeyPressed?: boolean | undefined) => void;
|
|
16
16
|
actionClickedEvent: (id: string, extensionKey: string, actionType: string, display: import("../../view/Card/types").CardInnerAppearance, invokeType: import("../../model/invoke-opts").InvokeType) => void;
|
|
17
17
|
closedAuthEvent: (display: import("../../view/Card/types").CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
18
18
|
renderSuccessEvent: (display: import("../../view/Card/types").CardInnerAppearance, id: string, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
@@ -22,8 +22,8 @@ export declare const connectFailedEvent: (definitionId?: string | undefined, ext
|
|
|
22
22
|
export declare const trackAppAccountConnected: (definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
23
23
|
export declare const uiAuthEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
24
24
|
export declare const uiAuthAlternateAccountEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
25
|
-
export declare const uiCardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
26
|
-
export declare const uiActionClickedEvent: (extensionKey: string, actionType: string, display?: "embed" | "block" | "inline" | "preview" | undefined) => AnalyticsPayload;
|
|
25
|
+
export declare const uiCardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined, isModifierKeyPressed?: boolean | undefined) => AnalyticsPayload;
|
|
26
|
+
export declare const uiActionClickedEvent: (extensionKey: string, actionType: string, display?: "embed" | "block" | "inline" | "preview" | "flexible" | undefined) => AnalyticsPayload;
|
|
27
27
|
export declare const uiClosedAuthEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
28
28
|
export declare const screenAuthPopupEvent: (definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
29
29
|
export declare const uiRenderSuccessEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => AnalyticsPayload;
|
|
@@ -10,7 +10,7 @@ export declare type BlockCardProps = {
|
|
|
10
10
|
authFlow?: CardAuthFlowOpts['authFlow'];
|
|
11
11
|
handleAuthorize: (() => void) | undefined;
|
|
12
12
|
handleErrorRetry: () => void;
|
|
13
|
-
|
|
13
|
+
handleAnalytics: AnalyticsHandler;
|
|
14
14
|
handleInvoke: InvokeHandler;
|
|
15
15
|
handleFrameClick: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
16
16
|
isSelected?: boolean;
|
|
@@ -4,7 +4,7 @@ import { JsonLd } from 'json-ld-types';
|
|
|
4
4
|
import { FlexibleUiOptions } from '../FlexibleCard/types';
|
|
5
5
|
import { InlinePreloaderStyle } from '../types';
|
|
6
6
|
export declare type CardAppearance = 'inline' | 'block' | 'embed';
|
|
7
|
-
export declare type CardInnerAppearance = CardAppearance | 'preview';
|
|
7
|
+
export declare type CardInnerAppearance = CardAppearance | 'preview' | 'flexible';
|
|
8
8
|
export declare type CardPlatform = JsonLd.Primitives.Platforms;
|
|
9
9
|
export declare type OnResolveCallback = (data: {
|
|
10
10
|
url?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ActionProps } from './action/types';
|
|
3
3
|
export declare const DeleteAction: import("react").FC<ActionProps>;
|
|
4
|
+
export declare const EditAction: import("react").FC<ActionProps>;
|
|
4
5
|
export declare const CustomAction: import("react").FC<ActionProps>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { BlockProps, ElementItem, ActionItem } from '../types';
|
|
2
3
|
import { SmartLinkPosition, SmartLinkTheme } from '../../../../../constants';
|
|
3
4
|
import { RetryOptions } from '../../../types';
|
|
@@ -11,4 +12,5 @@ export declare type TitleBlockProps = BlockProps & {
|
|
|
11
12
|
theme?: SmartLinkTheme;
|
|
12
13
|
text?: string;
|
|
13
14
|
showActionOnHover?: boolean;
|
|
15
|
+
onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
14
16
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SmartLinkSize, SmartLinkStatus, SmartLinkTheme } from '../../../../constants';
|
|
2
3
|
import { RetryOptions } from '../../types';
|
|
3
4
|
export declare type ContainerProps = {
|
|
@@ -9,4 +10,5 @@ export declare type ContainerProps = {
|
|
|
9
10
|
status?: SmartLinkStatus;
|
|
10
11
|
testId?: string;
|
|
11
12
|
theme?: SmartLinkTheme;
|
|
13
|
+
onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
12
14
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ElementProps } from '../types';
|
|
2
3
|
import { SmartLinkTheme } from '../../../../../constants';
|
|
3
4
|
export declare type LinkProps = ElementProps & {
|
|
5
|
+
onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
4
6
|
maxLines?: number;
|
|
5
7
|
text?: string;
|
|
6
8
|
theme?: SmartLinkTheme;
|