@atlaskit/smart-card 31.0.3 → 32.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/extractors/action/extractDownloadActionProps.js +28 -0
- package/dist/cjs/extractors/action/extractPreviewActionProps.js +43 -0
- package/dist/cjs/extractors/action/extractViewActionProps.js +27 -0
- package/dist/cjs/extractors/common/actions/extractActions.js +5 -0
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/cjs/extractors/common/actions/types.js +5 -0
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/cjs/utils/actions/to-action.js +18 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/action/extractDownloadActionProps.js +19 -0
- package/dist/es2019/extractors/action/extractPreviewActionProps.js +31 -0
- package/dist/es2019/extractors/action/extractViewActionProps.js +18 -0
- package/dist/es2019/extractors/common/actions/extractActions.js +5 -0
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/es2019/extractors/common/actions/types.js +1 -0
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/es2019/utils/actions/to-action.js +9 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/action/extractDownloadActionProps.js +22 -0
- package/dist/esm/extractors/action/extractPreviewActionProps.js +36 -0
- package/dist/esm/extractors/action/extractViewActionProps.js +21 -0
- package/dist/esm/extractors/common/actions/extractActions.js +5 -0
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/esm/extractors/common/actions/types.js +1 -0
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/esm/utils/actions/to-action.js +11 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/action/extractDownloadActionProps.d.ts +3 -0
- package/dist/types/extractors/action/extractPreviewActionProps.d.ts +3 -0
- package/dist/types/extractors/action/extractViewActionProps.d.ts +3 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +5 -0
- package/dist/types/extractors/common/actions/extractActions.d.ts +4 -0
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +4 -0
- package/dist/types/extractors/common/actions/types.d.ts +21 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +1 -0
- package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +2 -2
- package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +1 -0
- package/dist/types/utils/actions/to-action.d.ts +8 -0
- package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +5 -0
- package/dist/types-ts4.5/extractors/common/actions/extractActions.d.ts +4 -0
- package/dist/types-ts4.5/extractors/common/actions/extractPreviewAction.d.ts +4 -0
- package/dist/types-ts4.5/extractors/common/actions/types.d.ts +21 -0
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +1 -0
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +2 -2
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +1 -0
- package/dist/types-ts4.5/utils/actions/to-action.d.ts +8 -0
- package/package.json +4 -2
- package/client/package.json +0 -15
- package/dist/cjs/client/index.js +0 -12
- package/dist/es2019/client/index.js +0 -5
- package/dist/esm/client/index.js +0 -5
- package/dist/types/client/index.d.ts +0 -5
- package/dist/types-ts4.5/client/index.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 32.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#169454](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169454)
|
|
8
|
+
[`c4bdbc7fc7e2e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c4bdbc7fc7e2e) -
|
|
9
|
+
EDM-10924 Remove deprecated client entrypoint from smart-card
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#169491](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169491)
|
|
14
|
+
[`b0b713c370025`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b0b713c370025) -
|
|
15
|
+
Refactor useSmartLinkActions hook to remove dependency on extractBlockProps
|
|
16
|
+
|
|
3
17
|
## 31.0.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractDownloadActionProps = void 0;
|
|
7
|
+
var _constants = require("../../constants");
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
var _extractDownloadAction = require("../flexible/actions/extract-download-action");
|
|
10
|
+
var extractDownloadActionProps = exports.extractDownloadActionProps = function extractDownloadActionProps(_ref) {
|
|
11
|
+
var response = _ref.response,
|
|
12
|
+
actionOptions = _ref.actionOptions,
|
|
13
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
14
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
15
|
+
_ref$source = _ref.source,
|
|
16
|
+
source = _ref$source === void 0 ? 'block' : _ref$source;
|
|
17
|
+
var data = (0, _extractDownloadAction.extractDownloadAction)(response.data, actionOptions);
|
|
18
|
+
if (data) {
|
|
19
|
+
return {
|
|
20
|
+
actionType: _constants.ActionName.DownloadAction,
|
|
21
|
+
actionFn: function actionFn() {
|
|
22
|
+
return (0, _utils.downloadUrl)(data.downloadUrl);
|
|
23
|
+
},
|
|
24
|
+
display: source,
|
|
25
|
+
extensionKey: extensionKey
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.extractPreviewActionProps = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _constants = require("../../constants");
|
|
10
|
+
var _utils = require("../../view/EmbedModal/utils");
|
|
11
|
+
var _extractPreviewAction = require("../flexible/actions/extract-preview-action");
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
var extractPreviewActionProps = exports.extractPreviewActionProps = function extractPreviewActionProps(_ref) {
|
|
15
|
+
var response = _ref.response,
|
|
16
|
+
analytics = _ref.analytics,
|
|
17
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
18
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
19
|
+
_ref$source = _ref.source,
|
|
20
|
+
source = _ref$source === void 0 ? 'block' : _ref$source,
|
|
21
|
+
actionOptions = _ref.actionOptions,
|
|
22
|
+
origin = _ref.origin;
|
|
23
|
+
var data = (0, _extractPreviewAction.extractPreviewAction)(response, actionOptions);
|
|
24
|
+
if (data !== null && data !== void 0 && data.src) {
|
|
25
|
+
return {
|
|
26
|
+
actionType: _constants.ActionName.PreviewAction,
|
|
27
|
+
actionFn: function actionFn() {
|
|
28
|
+
return (0, _utils.openEmbedModal)(_objectSpread({
|
|
29
|
+
download: data === null || data === void 0 ? void 0 : data.downloadUrl,
|
|
30
|
+
showModal: true,
|
|
31
|
+
onClose: function onClose() {},
|
|
32
|
+
analytics: analytics,
|
|
33
|
+
extensionKey: extensionKey,
|
|
34
|
+
origin: origin
|
|
35
|
+
}, data));
|
|
36
|
+
},
|
|
37
|
+
// These values have already been set in analytics context.
|
|
38
|
+
// We only pass these here for ufo experience.
|
|
39
|
+
display: source,
|
|
40
|
+
extensionKey: extensionKey
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractViewActionProps = void 0;
|
|
7
|
+
var _utils = require("../../utils");
|
|
8
|
+
var _extractViewAction = require("../flexible/actions/extract-view-action");
|
|
9
|
+
var extractViewActionProps = exports.extractViewActionProps = function extractViewActionProps(_ref) {
|
|
10
|
+
var response = _ref.response,
|
|
11
|
+
actionOptions = _ref.actionOptions,
|
|
12
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
13
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
14
|
+
_ref$source = _ref.source,
|
|
15
|
+
source = _ref$source === void 0 ? 'block' : _ref$source;
|
|
16
|
+
var data = (0, _extractViewAction.extractViewAction)(response.data, actionOptions);
|
|
17
|
+
if (data) {
|
|
18
|
+
return {
|
|
19
|
+
actionType: 'ViewAction',
|
|
20
|
+
actionFn: function actionFn() {
|
|
21
|
+
return (0, _utils.openUrl)(data.viewUrl);
|
|
22
|
+
},
|
|
23
|
+
display: source,
|
|
24
|
+
extensionKey: extensionKey
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -65,6 +65,11 @@ var getActionsFromJsonLd = exports.getActionsFromJsonLd = function getActionsFro
|
|
|
65
65
|
}
|
|
66
66
|
return actions;
|
|
67
67
|
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @private
|
|
71
|
+
* @deprecated - use flexible extractors instead
|
|
72
|
+
*/
|
|
68
73
|
function extractClientActions(jsonLd, handler, actionOptions) {
|
|
69
74
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
70
75
|
var clientActions = actions.filter(function (action) {
|
|
@@ -54,6 +54,11 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
61
|
+
*/
|
|
57
62
|
var extractPreviewAction = exports.extractPreviewAction = function extractPreviewAction(_ref) {
|
|
58
63
|
var _ref$extensionKey = _ref.extensionKey,
|
|
59
64
|
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
@@ -9,6 +9,7 @@ var _canShowAction = require("../../../utils/actions/can-show-action");
|
|
|
9
9
|
var _types = require("../../../view/Card/types");
|
|
10
10
|
var _detail = require("../../common/detail");
|
|
11
11
|
var _extractIsSupportTheming = require("../../common/meta/extractIsSupportTheming");
|
|
12
|
+
var _extractIsTrusted = require("../../common/meta/extractIsTrusted");
|
|
12
13
|
var _icon = require("../icon");
|
|
13
14
|
var extractPreviewAction = exports.extractPreviewAction = function extractPreviewAction(response, actionOptions) {
|
|
14
15
|
var _extractPreviewData;
|
|
@@ -27,7 +28,8 @@ var extractPreviewAction = exports.extractPreviewAction = function extractPrevie
|
|
|
27
28
|
title: (0, _linkExtractors.extractTitle)(data),
|
|
28
29
|
linkIcon: (0, _icon.extractLinkIcon)(response),
|
|
29
30
|
url: (0, _linkExtractors.extractLink)(data),
|
|
30
|
-
isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta)
|
|
31
|
+
isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta),
|
|
32
|
+
isTrusted: (0, _extractIsTrusted.extractIsTrusted)(meta)
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
};
|
|
@@ -7,10 +7,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useSmartLinkActions = useSmartLinkActions;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _extractDownloadActionProps = require("../../extractors/action/extractDownloadActionProps");
|
|
12
|
+
var _extractPreviewActionProps = require("../../extractors/action/extractPreviewActionProps");
|
|
13
|
+
var _extractViewActionProps = require("../../extractors/action/extractViewActionProps");
|
|
10
14
|
var _block = require("../../extractors/block");
|
|
15
|
+
var _messages = require("../../messages");
|
|
16
|
+
var _toAction = require("../../utils/actions/to-action");
|
|
11
17
|
var _actions = require("../actions");
|
|
12
18
|
var _analytics = require("../analytics");
|
|
13
19
|
var _helpers = require("../helpers");
|
|
20
|
+
var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
|
|
14
21
|
var _store = require("../store");
|
|
15
22
|
function useSmartLinkActions(_ref) {
|
|
16
23
|
var url = _ref.url,
|
|
@@ -25,6 +32,37 @@ function useSmartLinkActions(_ref) {
|
|
|
25
32
|
var linkState = (0, _store.useSmartCardState)(url);
|
|
26
33
|
var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, id);
|
|
27
34
|
var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
|
|
35
|
+
var invokeClientAction = (0, _useInvokeClientAction.default)({
|
|
36
|
+
analytics: linkAnalytics
|
|
37
|
+
});
|
|
38
|
+
if ((0, _platformFeatureFlags.fg)('smart-card-use-refactored-usesmartlinkactions')) {
|
|
39
|
+
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
40
|
+
var opts = {
|
|
41
|
+
response: linkState.details,
|
|
42
|
+
handleInvoke: invokeClientAction,
|
|
43
|
+
analytics: linkAnalytics,
|
|
44
|
+
origin: origin,
|
|
45
|
+
extensionKey: (0, _helpers.getExtensionKey)(linkState.details),
|
|
46
|
+
source: appearance,
|
|
47
|
+
actionOptions: actionOptions
|
|
48
|
+
};
|
|
49
|
+
var actions = [];
|
|
50
|
+
var downloadActionProps = (0, _extractDownloadActionProps.extractDownloadActionProps)(opts);
|
|
51
|
+
if (downloadActionProps) {
|
|
52
|
+
actions.push((0, _toAction.toAction)(downloadActionProps, invokeClientAction, _messages.messages.download, 'download-content'));
|
|
53
|
+
}
|
|
54
|
+
var viewActionProps = (0, _extractViewActionProps.extractViewActionProps)(opts);
|
|
55
|
+
if (viewActionProps) {
|
|
56
|
+
actions.push((0, _toAction.toAction)(viewActionProps, invokeClientAction, _messages.messages.view, 'view-content'));
|
|
57
|
+
}
|
|
58
|
+
var previewActionProps = (0, _extractPreviewActionProps.extractPreviewActionProps)(opts);
|
|
59
|
+
if (previewActionProps) {
|
|
60
|
+
actions.push((0, _toAction.toAction)(previewActionProps, invokeClientAction, _messages.messages.preview_improved, 'preview-content'));
|
|
61
|
+
}
|
|
62
|
+
return actions;
|
|
63
|
+
}
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
28
66
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
29
67
|
var cardProperties = (0, _block.extractBlockProps)(linkState.details.data, linkState.details.meta, {
|
|
30
68
|
handleInvoke: function handleInvoke(opts) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.toAction = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var toAction = exports.toAction = function toAction(action, invokeClientAction, message, id) {
|
|
11
|
+
return {
|
|
12
|
+
id: id,
|
|
13
|
+
text: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, message),
|
|
14
|
+
invoke: function invoke() {
|
|
15
|
+
return invokeClientAction(action);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -17,7 +17,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
17
17
|
var context = exports.context = {
|
|
18
18
|
componentName: 'smart-cards',
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "
|
|
20
|
+
packageVersion: "32.0.0"
|
|
21
21
|
};
|
|
22
22
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
23
23
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
17
17
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
18
18
|
var PACKAGE_DATA = {
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "
|
|
20
|
+
packageVersion: "32.0.0",
|
|
21
21
|
componentName: 'linkUrl'
|
|
22
22
|
};
|
|
23
23
|
var Link = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionName } from '../../constants';
|
|
2
|
+
import { downloadUrl } from '../../utils';
|
|
3
|
+
import { extractDownloadAction as extractDownloadActionData } from '../flexible/actions/extract-download-action';
|
|
4
|
+
export const extractDownloadActionProps = ({
|
|
5
|
+
response,
|
|
6
|
+
actionOptions,
|
|
7
|
+
extensionKey = 'empty-object-provider',
|
|
8
|
+
source = 'block'
|
|
9
|
+
}) => {
|
|
10
|
+
const data = extractDownloadActionData(response.data, actionOptions);
|
|
11
|
+
if (data) {
|
|
12
|
+
return {
|
|
13
|
+
actionType: ActionName.DownloadAction,
|
|
14
|
+
actionFn: () => downloadUrl(data.downloadUrl),
|
|
15
|
+
display: source,
|
|
16
|
+
extensionKey
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ActionName } from '../../constants';
|
|
2
|
+
import { openEmbedModal } from '../../view/EmbedModal/utils';
|
|
3
|
+
import { extractPreviewAction as extractPreviewActionData } from '../flexible/actions/extract-preview-action';
|
|
4
|
+
export const extractPreviewActionProps = ({
|
|
5
|
+
response,
|
|
6
|
+
analytics,
|
|
7
|
+
extensionKey = 'empty-object-provider',
|
|
8
|
+
source = 'block',
|
|
9
|
+
actionOptions,
|
|
10
|
+
origin
|
|
11
|
+
}) => {
|
|
12
|
+
const data = extractPreviewActionData(response, actionOptions);
|
|
13
|
+
if (data !== null && data !== void 0 && data.src) {
|
|
14
|
+
return {
|
|
15
|
+
actionType: ActionName.PreviewAction,
|
|
16
|
+
actionFn: () => openEmbedModal({
|
|
17
|
+
download: data === null || data === void 0 ? void 0 : data.downloadUrl,
|
|
18
|
+
showModal: true,
|
|
19
|
+
onClose: () => {},
|
|
20
|
+
analytics,
|
|
21
|
+
extensionKey,
|
|
22
|
+
origin,
|
|
23
|
+
...data
|
|
24
|
+
}),
|
|
25
|
+
// These values have already been set in analytics context.
|
|
26
|
+
// We only pass these here for ufo experience.
|
|
27
|
+
display: source,
|
|
28
|
+
extensionKey
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { openUrl } from '../../utils';
|
|
2
|
+
import { extractViewAction as extractViewActionData } from '../flexible/actions/extract-view-action';
|
|
3
|
+
export const extractViewActionProps = ({
|
|
4
|
+
response,
|
|
5
|
+
actionOptions,
|
|
6
|
+
extensionKey = 'empty-object-provider',
|
|
7
|
+
source = 'block'
|
|
8
|
+
}) => {
|
|
9
|
+
const data = extractViewActionData(response.data, actionOptions);
|
|
10
|
+
if (data) {
|
|
11
|
+
return {
|
|
12
|
+
actionType: 'ViewAction',
|
|
13
|
+
actionFn: () => openUrl(data.viewUrl),
|
|
14
|
+
display: source,
|
|
15
|
+
extensionKey
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -51,6 +51,11 @@ export const getActionsFromJsonLd = jsonLd => {
|
|
|
51
51
|
}
|
|
52
52
|
return actions;
|
|
53
53
|
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @deprecated - use flexible extractors instead
|
|
58
|
+
*/
|
|
54
59
|
export function extractClientActions(jsonLd, handler, actionOptions) {
|
|
55
60
|
const actions = getActionsFromJsonLd(jsonLd);
|
|
56
61
|
const clientActions = actions.filter(action => isClientAction(action) && isActionEnabled(action, actionOptions));
|
|
@@ -38,6 +38,11 @@ const getInvokeOpts = (key, action, source) => ({
|
|
|
38
38
|
promise: () => Promise.resolve()
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
45
|
+
*/
|
|
41
46
|
export const extractPreviewAction = ({
|
|
42
47
|
extensionKey = 'empty-object-provider',
|
|
43
48
|
viewProps,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import { canShowAction } from '../../../utils/actions/can-show-action';
|
|
|
3
3
|
import { CardAction } from '../../../view/Card/types';
|
|
4
4
|
import { extractDownloadUrl } from '../../common/detail';
|
|
5
5
|
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
6
|
+
import { extractIsTrusted } from '../../common/meta/extractIsTrusted';
|
|
6
7
|
import { extractLinkIcon } from '../icon';
|
|
7
8
|
export const extractPreviewAction = (response, actionOptions) => {
|
|
8
9
|
var _extractPreviewData;
|
|
@@ -21,7 +22,8 @@ export const extractPreviewAction = (response, actionOptions) => {
|
|
|
21
22
|
title: extractTitle(data),
|
|
22
23
|
linkIcon: extractLinkIcon(response),
|
|
23
24
|
url: extractLink(data),
|
|
24
|
-
isSupportTheming: extractIsSupportTheming(meta)
|
|
25
|
+
isSupportTheming: extractIsSupportTheming(meta),
|
|
26
|
+
isTrusted: extractIsTrusted(meta)
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
5
|
+
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
6
|
+
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
3
7
|
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
8
|
+
import { messages } from '../../messages';
|
|
9
|
+
import { toAction } from '../../utils/actions/to-action';
|
|
4
10
|
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
5
11
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
6
12
|
import { getExtensionKey } from '../helpers';
|
|
13
|
+
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
7
14
|
import { useSmartCardState as useLinkState } from '../store';
|
|
8
15
|
export function useSmartLinkActions({
|
|
9
16
|
url,
|
|
@@ -16,6 +23,37 @@ export function useSmartLinkActions({
|
|
|
16
23
|
const linkState = useLinkState(url);
|
|
17
24
|
const linkAnalytics = useLinkAnalytics(url, id);
|
|
18
25
|
const linkActions = useLinkActions(id, url, linkAnalytics);
|
|
26
|
+
const invokeClientAction = useInvokeClientAction({
|
|
27
|
+
analytics: linkAnalytics
|
|
28
|
+
});
|
|
29
|
+
if (fg('smart-card-use-refactored-usesmartlinkactions')) {
|
|
30
|
+
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
31
|
+
const opts = {
|
|
32
|
+
response: linkState.details,
|
|
33
|
+
handleInvoke: invokeClientAction,
|
|
34
|
+
analytics: linkAnalytics,
|
|
35
|
+
origin,
|
|
36
|
+
extensionKey: getExtensionKey(linkState.details),
|
|
37
|
+
source: appearance,
|
|
38
|
+
actionOptions
|
|
39
|
+
};
|
|
40
|
+
const actions = [];
|
|
41
|
+
const downloadActionProps = extractDownloadActionProps(opts);
|
|
42
|
+
if (downloadActionProps) {
|
|
43
|
+
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
44
|
+
}
|
|
45
|
+
const viewActionProps = extractViewActionProps(opts);
|
|
46
|
+
if (viewActionProps) {
|
|
47
|
+
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
48
|
+
}
|
|
49
|
+
const previewActionProps = extractPreviewActionProps(opts);
|
|
50
|
+
if (previewActionProps) {
|
|
51
|
+
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
52
|
+
}
|
|
53
|
+
return actions;
|
|
54
|
+
}
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
19
57
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
20
58
|
const cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
|
|
21
59
|
handleInvoke: opts => linkActions.invoke(opts, appearance),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
export const toAction = (action, invokeClientAction, message, id) => {
|
|
4
|
+
return {
|
|
5
|
+
id,
|
|
6
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, message),
|
|
7
|
+
invoke: () => invokeClientAction(action)
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export const context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "
|
|
7
|
+
packageVersion: "32.0.0"
|
|
8
8
|
};
|
|
9
9
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -7,7 +7,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
7
7
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
8
8
|
const PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/smart-card",
|
|
10
|
-
packageVersion: "
|
|
10
|
+
packageVersion: "32.0.0",
|
|
11
11
|
componentName: 'linkUrl'
|
|
12
12
|
};
|
|
13
13
|
const Link = withLinkClickedEvent('a');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ActionName } from '../../constants';
|
|
2
|
+
import { downloadUrl } from '../../utils';
|
|
3
|
+
import { extractDownloadAction as extractDownloadActionData } from '../flexible/actions/extract-download-action';
|
|
4
|
+
export var extractDownloadActionProps = function extractDownloadActionProps(_ref) {
|
|
5
|
+
var response = _ref.response,
|
|
6
|
+
actionOptions = _ref.actionOptions,
|
|
7
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
8
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
9
|
+
_ref$source = _ref.source,
|
|
10
|
+
source = _ref$source === void 0 ? 'block' : _ref$source;
|
|
11
|
+
var data = extractDownloadActionData(response.data, actionOptions);
|
|
12
|
+
if (data) {
|
|
13
|
+
return {
|
|
14
|
+
actionType: ActionName.DownloadAction,
|
|
15
|
+
actionFn: function actionFn() {
|
|
16
|
+
return downloadUrl(data.downloadUrl);
|
|
17
|
+
},
|
|
18
|
+
display: source,
|
|
19
|
+
extensionKey: extensionKey
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { ActionName } from '../../constants';
|
|
5
|
+
import { openEmbedModal } from '../../view/EmbedModal/utils';
|
|
6
|
+
import { extractPreviewAction as extractPreviewActionData } from '../flexible/actions/extract-preview-action';
|
|
7
|
+
export var extractPreviewActionProps = function extractPreviewActionProps(_ref) {
|
|
8
|
+
var response = _ref.response,
|
|
9
|
+
analytics = _ref.analytics,
|
|
10
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
11
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
12
|
+
_ref$source = _ref.source,
|
|
13
|
+
source = _ref$source === void 0 ? 'block' : _ref$source,
|
|
14
|
+
actionOptions = _ref.actionOptions,
|
|
15
|
+
origin = _ref.origin;
|
|
16
|
+
var data = extractPreviewActionData(response, actionOptions);
|
|
17
|
+
if (data !== null && data !== void 0 && data.src) {
|
|
18
|
+
return {
|
|
19
|
+
actionType: ActionName.PreviewAction,
|
|
20
|
+
actionFn: function actionFn() {
|
|
21
|
+
return openEmbedModal(_objectSpread({
|
|
22
|
+
download: data === null || data === void 0 ? void 0 : data.downloadUrl,
|
|
23
|
+
showModal: true,
|
|
24
|
+
onClose: function onClose() {},
|
|
25
|
+
analytics: analytics,
|
|
26
|
+
extensionKey: extensionKey,
|
|
27
|
+
origin: origin
|
|
28
|
+
}, data));
|
|
29
|
+
},
|
|
30
|
+
// These values have already been set in analytics context.
|
|
31
|
+
// We only pass these here for ufo experience.
|
|
32
|
+
display: source,
|
|
33
|
+
extensionKey: extensionKey
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { openUrl } from '../../utils';
|
|
2
|
+
import { extractViewAction as extractViewActionData } from '../flexible/actions/extract-view-action';
|
|
3
|
+
export var extractViewActionProps = function extractViewActionProps(_ref) {
|
|
4
|
+
var response = _ref.response,
|
|
5
|
+
actionOptions = _ref.actionOptions,
|
|
6
|
+
_ref$extensionKey = _ref.extensionKey,
|
|
7
|
+
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
8
|
+
_ref$source = _ref.source,
|
|
9
|
+
source = _ref$source === void 0 ? 'block' : _ref$source;
|
|
10
|
+
var data = extractViewActionData(response.data, actionOptions);
|
|
11
|
+
if (data) {
|
|
12
|
+
return {
|
|
13
|
+
actionType: 'ViewAction',
|
|
14
|
+
actionFn: function actionFn() {
|
|
15
|
+
return openUrl(data.viewUrl);
|
|
16
|
+
},
|
|
17
|
+
display: source,
|
|
18
|
+
extensionKey: extensionKey
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -57,6 +57,11 @@ export var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
|
57
57
|
}
|
|
58
58
|
return actions;
|
|
59
59
|
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
* @deprecated - use flexible extractors instead
|
|
64
|
+
*/
|
|
60
65
|
export function extractClientActions(jsonLd, handler, actionOptions) {
|
|
61
66
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
62
67
|
var clientActions = actions.filter(function (action) {
|
|
@@ -47,6 +47,11 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @private
|
|
53
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
54
|
+
*/
|
|
50
55
|
export var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
51
56
|
var _ref$extensionKey = _ref.extensionKey,
|
|
52
57
|
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import { canShowAction } from '../../../utils/actions/can-show-action';
|
|
|
3
3
|
import { CardAction } from '../../../view/Card/types';
|
|
4
4
|
import { extractDownloadUrl } from '../../common/detail';
|
|
5
5
|
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
6
|
+
import { extractIsTrusted } from '../../common/meta/extractIsTrusted';
|
|
6
7
|
import { extractLinkIcon } from '../icon';
|
|
7
8
|
export var extractPreviewAction = function extractPreviewAction(response, actionOptions) {
|
|
8
9
|
var _extractPreviewData;
|
|
@@ -21,7 +22,8 @@ export var extractPreviewAction = function extractPreviewAction(response, action
|
|
|
21
22
|
title: extractTitle(data),
|
|
22
23
|
linkIcon: extractLinkIcon(response),
|
|
23
24
|
url: extractLink(data),
|
|
24
|
-
isSupportTheming: extractIsSupportTheming(meta)
|
|
25
|
+
isSupportTheming: extractIsSupportTheming(meta),
|
|
26
|
+
isTrusted: extractIsTrusted(meta)
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
5
|
+
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
6
|
+
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
3
7
|
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
8
|
+
import { messages } from '../../messages';
|
|
9
|
+
import { toAction } from '../../utils/actions/to-action';
|
|
4
10
|
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
5
11
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
6
12
|
import { getExtensionKey } from '../helpers';
|
|
13
|
+
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
7
14
|
import { useSmartCardState as useLinkState } from '../store';
|
|
8
15
|
export function useSmartLinkActions(_ref) {
|
|
9
16
|
var url = _ref.url,
|
|
@@ -18,6 +25,37 @@ export function useSmartLinkActions(_ref) {
|
|
|
18
25
|
var linkState = useLinkState(url);
|
|
19
26
|
var linkAnalytics = useLinkAnalytics(url, id);
|
|
20
27
|
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
28
|
+
var invokeClientAction = useInvokeClientAction({
|
|
29
|
+
analytics: linkAnalytics
|
|
30
|
+
});
|
|
31
|
+
if (fg('smart-card-use-refactored-usesmartlinkactions')) {
|
|
32
|
+
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
33
|
+
var opts = {
|
|
34
|
+
response: linkState.details,
|
|
35
|
+
handleInvoke: invokeClientAction,
|
|
36
|
+
analytics: linkAnalytics,
|
|
37
|
+
origin: origin,
|
|
38
|
+
extensionKey: getExtensionKey(linkState.details),
|
|
39
|
+
source: appearance,
|
|
40
|
+
actionOptions: actionOptions
|
|
41
|
+
};
|
|
42
|
+
var actions = [];
|
|
43
|
+
var downloadActionProps = extractDownloadActionProps(opts);
|
|
44
|
+
if (downloadActionProps) {
|
|
45
|
+
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
46
|
+
}
|
|
47
|
+
var viewActionProps = extractViewActionProps(opts);
|
|
48
|
+
if (viewActionProps) {
|
|
49
|
+
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
50
|
+
}
|
|
51
|
+
var previewActionProps = extractPreviewActionProps(opts);
|
|
52
|
+
if (previewActionProps) {
|
|
53
|
+
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
54
|
+
}
|
|
55
|
+
return actions;
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
21
59
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
22
60
|
var cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
|
|
23
61
|
handleInvoke: function handleInvoke(opts) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
export var toAction = function toAction(action, invokeClientAction, message, id) {
|
|
4
|
+
return {
|
|
5
|
+
id: id,
|
|
6
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, message),
|
|
7
|
+
invoke: function invoke() {
|
|
8
|
+
return invokeClientAction(action);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -10,7 +10,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
10
10
|
export var context = {
|
|
11
11
|
componentName: 'smart-cards',
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "
|
|
13
|
+
packageVersion: "32.0.0"
|
|
14
14
|
};
|
|
15
15
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
16
16
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
10
10
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "
|
|
13
|
+
packageVersion: "32.0.0",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractDownloadActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import type { ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractPreviewActionProps: ({ response, analytics, extensionKey, source, actionOptions, origin, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractViewActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -41,3 +41,8 @@ export declare const PREVIEW: JsonLd.Data.BaseData['preview'];
|
|
|
41
41
|
export declare const TEST_DOCUMENT_WITH_PREVIEW: JsonLd.Data.BaseData;
|
|
42
42
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_OBJ: JsonLd.Data.SourceCodeRepository;
|
|
43
43
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_TEXT: JsonLd.Data.SourceCodeRepository;
|
|
44
|
+
export declare const TEST_RESPONSE: JsonLd.Response;
|
|
45
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW_AND_DOWNLOAD: JsonLd.Response;
|
|
46
|
+
export declare const TEST_RESPONSE_WITH_DOWNLOAD: JsonLd.Response;
|
|
47
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW: JsonLd.Response;
|
|
48
|
+
export declare const TEST_RESPONSE_WITH_VIEW: JsonLd.Response;
|
|
@@ -3,4 +3,8 @@ import { type InvokeHandler } from '../../../model/invoke-handler';
|
|
|
3
3
|
import { type ActionProps } from '../../../view/BlockCard/components/Action';
|
|
4
4
|
import { type CardActionOptions } from '../../../view/Card/types';
|
|
5
5
|
export declare const getActionsFromJsonLd: (jsonLd: JsonLd.Data.BaseData) => JsonLd.Primitives.Action[];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated - use flexible extractors instead
|
|
9
|
+
*/
|
|
6
10
|
export declare function extractClientActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler, actionOptions?: CardActionOptions): ActionProps[];
|
|
@@ -2,6 +2,10 @@ import { type JsonLd } from 'json-ld-types';
|
|
|
2
2
|
import { type BlockCardResolvedViewProps } from '../../../view/BlockCard';
|
|
3
3
|
import { type CardPlatform } from '../../../view/Card/types';
|
|
4
4
|
import { type ExtractBlockOpts } from '../../block/types';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
8
|
+
*/
|
|
5
9
|
export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, analytics, meta, actionOptions, }: ExtractBlockOpts & {
|
|
6
10
|
viewProps: BlockCardResolvedViewProps;
|
|
7
11
|
jsonLd: JsonLd.Data.BaseData;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type JsonLd } from 'json-ld-types';
|
|
3
|
+
import { type AnalyticsFacade } from '../../../state/analytics';
|
|
4
|
+
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
5
|
+
import { type CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
6
|
+
export type ExtractActionsProps = {
|
|
7
|
+
response: JsonLd.Response;
|
|
8
|
+
analytics: AnalyticsFacade;
|
|
9
|
+
actionOptions?: CardActionOptions;
|
|
10
|
+
extensionKey?: string;
|
|
11
|
+
source?: CardInnerAppearance;
|
|
12
|
+
origin?: AnalyticsOrigin;
|
|
13
|
+
};
|
|
14
|
+
export interface ActionProps {
|
|
15
|
+
/** String identifier for the action (e.g. 'preview-content') */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The text to be displayed in the action's button */
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
/** The function to be called on clicking the action. This is a promise so the state can transition correctly after the action finishes */
|
|
20
|
+
invoke: () => Promise<any>;
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InvokeClientActionHandler, UseInvokeClientActionProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke client action such as preview, download and open link
|
|
4
4
|
*/
|
|
5
|
-
declare const useInvokeClientAction: ({ analytics }: UseInvokeClientActionProps) =>
|
|
5
|
+
declare const useInvokeClientAction: ({ analytics, }: UseInvokeClientActionProps) => InvokeClientActionHandler;
|
|
6
6
|
export default useInvokeClientAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import { type InvokeClientActionHandler, type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
4
|
+
export declare const toAction: (action: InvokeClientActionProps, invokeClientAction: InvokeClientActionHandler, message: MessageDescriptor, id: string) => {
|
|
5
|
+
id: string;
|
|
6
|
+
text: JSX.Element;
|
|
7
|
+
invoke: () => Promise<void>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractDownloadActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import type { ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractPreviewActionProps: ({ response, analytics, extensionKey, source, actionOptions, origin, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractViewActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -41,3 +41,8 @@ export declare const PREVIEW: JsonLd.Data.BaseData['preview'];
|
|
|
41
41
|
export declare const TEST_DOCUMENT_WITH_PREVIEW: JsonLd.Data.BaseData;
|
|
42
42
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_OBJ: JsonLd.Data.SourceCodeRepository;
|
|
43
43
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_TEXT: JsonLd.Data.SourceCodeRepository;
|
|
44
|
+
export declare const TEST_RESPONSE: JsonLd.Response;
|
|
45
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW_AND_DOWNLOAD: JsonLd.Response;
|
|
46
|
+
export declare const TEST_RESPONSE_WITH_DOWNLOAD: JsonLd.Response;
|
|
47
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW: JsonLd.Response;
|
|
48
|
+
export declare const TEST_RESPONSE_WITH_VIEW: JsonLd.Response;
|
|
@@ -3,4 +3,8 @@ import { type InvokeHandler } from '../../../model/invoke-handler';
|
|
|
3
3
|
import { type ActionProps } from '../../../view/BlockCard/components/Action';
|
|
4
4
|
import { type CardActionOptions } from '../../../view/Card/types';
|
|
5
5
|
export declare const getActionsFromJsonLd: (jsonLd: JsonLd.Data.BaseData) => JsonLd.Primitives.Action[];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated - use flexible extractors instead
|
|
9
|
+
*/
|
|
6
10
|
export declare function extractClientActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler, actionOptions?: CardActionOptions): ActionProps[];
|
|
@@ -2,6 +2,10 @@ import { type JsonLd } from 'json-ld-types';
|
|
|
2
2
|
import { type BlockCardResolvedViewProps } from '../../../view/BlockCard';
|
|
3
3
|
import { type CardPlatform } from '../../../view/Card/types';
|
|
4
4
|
import { type ExtractBlockOpts } from '../../block/types';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
8
|
+
*/
|
|
5
9
|
export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, analytics, meta, actionOptions, }: ExtractBlockOpts & {
|
|
6
10
|
viewProps: BlockCardResolvedViewProps;
|
|
7
11
|
jsonLd: JsonLd.Data.BaseData;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type JsonLd } from 'json-ld-types';
|
|
3
|
+
import { type AnalyticsFacade } from '../../../state/analytics';
|
|
4
|
+
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
5
|
+
import { type CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
6
|
+
export type ExtractActionsProps = {
|
|
7
|
+
response: JsonLd.Response;
|
|
8
|
+
analytics: AnalyticsFacade;
|
|
9
|
+
actionOptions?: CardActionOptions;
|
|
10
|
+
extensionKey?: string;
|
|
11
|
+
source?: CardInnerAppearance;
|
|
12
|
+
origin?: AnalyticsOrigin;
|
|
13
|
+
};
|
|
14
|
+
export interface ActionProps {
|
|
15
|
+
/** String identifier for the action (e.g. 'preview-content') */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The text to be displayed in the action's button */
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
/** The function to be called on clicking the action. This is a promise so the state can transition correctly after the action finishes */
|
|
20
|
+
invoke: () => Promise<any>;
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InvokeClientActionHandler, UseInvokeClientActionProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke client action such as preview, download and open link
|
|
4
4
|
*/
|
|
5
|
-
declare const useInvokeClientAction: ({ analytics }: UseInvokeClientActionProps) =>
|
|
5
|
+
declare const useInvokeClientAction: ({ analytics, }: UseInvokeClientActionProps) => InvokeClientActionHandler;
|
|
6
6
|
export default useInvokeClientAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import { type InvokeClientActionHandler, type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
4
|
+
export declare const toAction: (action: InvokeClientActionProps, invokeClientAction: InvokeClientActionHandler, message: MessageDescriptor, id: string) => {
|
|
5
|
+
id: string;
|
|
6
|
+
text: JSX.Element;
|
|
7
|
+
invoke: () => Promise<void>;
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "32.0.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -152,7 +152,6 @@
|
|
|
152
152
|
},
|
|
153
153
|
"af:exports": {
|
|
154
154
|
"./ssr": "./src/ssr.tsx",
|
|
155
|
-
"./client": "./src/client/index.ts",
|
|
156
155
|
"./types": "./src/types.ts",
|
|
157
156
|
"./hooks": "./src/hooks.ts",
|
|
158
157
|
"./hover-card": "./src/hoverCard.ts",
|
|
@@ -174,6 +173,9 @@
|
|
|
174
173
|
},
|
|
175
174
|
"smart_links_for_plans_platform": {
|
|
176
175
|
"type": "boolean"
|
|
176
|
+
},
|
|
177
|
+
"smart-card-use-refactored-usesmartlinkactions": {
|
|
178
|
+
"type": "boolean"
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
}
|
package/client/package.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/smart-card/client",
|
|
3
|
-
"main": "../dist/cjs/client/index.js",
|
|
4
|
-
"module": "../dist/esm/client/index.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/client/index.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/client/index.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/client/index.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
package/dist/cjs/client/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _linkProvider.CardClient;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _linkProvider = require("@atlaskit/link-provider");
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
package/dist/esm/client/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|