@atlaskit/smart-card 23.3.1 → 23.4.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 +34 -0
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/extractors/common/actions/extractActions.js +3 -0
- package/dist/cjs/extractors/flexible/actions/extract-download-action.js +26 -0
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +36 -0
- package/dist/cjs/extractors/flexible/actions/extract-view-action.js +26 -0
- package/dist/cjs/extractors/flexible/index.js +9 -0
- package/dist/cjs/state/flexible-ui-context/index.js +15 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +110 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +167 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +92 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +26 -2
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +51 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/index.js +6 -3
- package/dist/cjs/view/common/Icon.js +25 -13
- package/dist/es2019/constants.js +3 -0
- package/dist/es2019/extractors/common/actions/extractActions.js +1 -2
- package/dist/es2019/extractors/flexible/actions/extract-download-action.js +13 -0
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +23 -0
- package/dist/es2019/extractors/flexible/actions/extract-view-action.js +13 -0
- package/dist/es2019/extractors/flexible/index.js +7 -1
- package/dist/es2019/state/flexible-ui-context/index.js +8 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +66 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +104 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +46 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +23 -2
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +48 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +12 -9
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/index.js +7 -4
- package/dist/es2019/view/common/Icon.js +31 -13
- package/dist/esm/constants.js +3 -0
- package/dist/esm/extractors/common/actions/extractActions.js +1 -2
- package/dist/esm/extractors/flexible/actions/extract-download-action.js +15 -0
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +23 -0
- package/dist/esm/extractors/flexible/actions/extract-view-action.js +15 -0
- package/dist/esm/extractors/flexible/index.js +7 -1
- package/dist/esm/state/flexible-ui-context/index.js +9 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +96 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +136 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +77 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +23 -2
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +45 -2
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/esm/view/FlexibleCard/index.js +7 -4
- package/dist/esm/view/common/Icon.js +27 -13
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +112 -0
- package/dist/types/extractors/common/actions/extractActions.d.ts +1 -0
- package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +3 -0
- package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +3 -0
- package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +76 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +32 -0
- package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +2 -2
- package/dist/types/view/EmbedModal/index.d.ts +20 -2
- package/dist/types/view/EmbedModal/types.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +15 -0
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +21 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +50 -3
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
- package/dist/types/view/FlexibleCard/types.d.ts +6 -0
- package/dist/types/view/common/Icon.d.ts +2 -1
- package/package.json +1 -1
- package/report.api.md +30 -2
- package/tmp/api-report-tmp.d.ts +25 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 23.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a86403e5e0e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a86403e5e0e) - [ux] This PR adds more actions for use in Flexible UI Smart Links. These are PreviewAction, ViewAction and DownloadAction, and correspond to their Block card counterparts.
|
|
8
|
+
|
|
9
|
+
These, unlike the existing actions, will only render when the data for them is available. Therefore, the onClick for these actions are optional.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
|
|
13
|
+
```TSX
|
|
14
|
+
const actions = [
|
|
15
|
+
{
|
|
16
|
+
name: ActionName.PreviewAction,
|
|
17
|
+
onClick: () => console.log('Preview action!'), // will run in addition to normal Preview Action
|
|
18
|
+
...options,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: ActionName.ViewAction,
|
|
22
|
+
onClick: () => console.log('View action!'), // will run in addition to normal View Action
|
|
23
|
+
...options,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: ActionName.DownloadAction,
|
|
27
|
+
onClick: () => console.log('Download action!'), // will run in addition to normal Download Action
|
|
28
|
+
...options,
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
<Card>
|
|
33
|
+
<TitleBlock actions={actions}>
|
|
34
|
+
</Card>
|
|
35
|
+
```
|
|
36
|
+
|
|
3
37
|
## 23.3.1
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/cjs/constants.js
CHANGED
|
@@ -167,6 +167,9 @@ exports.ActionName = ActionName;
|
|
|
167
167
|
(function (ActionName) {
|
|
168
168
|
ActionName["DeleteAction"] = "DeleteAction";
|
|
169
169
|
ActionName["EditAction"] = "EditAction";
|
|
170
|
+
ActionName["PreviewAction"] = "PreviewAction";
|
|
171
|
+
ActionName["ViewAction"] = "ViewAction";
|
|
172
|
+
ActionName["DownloadAction"] = "DownloadAction";
|
|
170
173
|
ActionName["CustomAction"] = "CustomAction";
|
|
171
174
|
})(ActionName || (exports.ActionName = ActionName = {}));
|
|
172
175
|
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.extractActions = extractActions;
|
|
9
|
+
exports.getActionsFromJsonLd = void 0;
|
|
9
10
|
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
|
|
@@ -92,6 +93,8 @@ var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
|
92
93
|
return actions;
|
|
93
94
|
};
|
|
94
95
|
|
|
96
|
+
exports.getActionsFromJsonLd = getActionsFromJsonLd;
|
|
97
|
+
|
|
95
98
|
function extractActions(jsonLd, handler) {
|
|
96
99
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
97
100
|
var clientActions = actions.filter(isClientAction);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractDownloadAction = void 0;
|
|
7
|
+
|
|
8
|
+
var _extractActions = require("../../common/actions/extractActions");
|
|
9
|
+
|
|
10
|
+
var _detail = require("../../common/detail");
|
|
11
|
+
|
|
12
|
+
var extractDownloadAction = function extractDownloadAction(data) {
|
|
13
|
+
var downloadActionExists = (0, _extractActions.getActionsFromJsonLd)(data).find(function (action) {
|
|
14
|
+
return action['@type'] === 'DownloadAction';
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (downloadActionExists) {
|
|
18
|
+
return {
|
|
19
|
+
downloadUrl: (0, _detail.extractDownloadUrl)(data)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.extractDownloadAction = extractDownloadAction;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractPreviewAction = void 0;
|
|
7
|
+
|
|
8
|
+
var _detail = require("../../common/detail");
|
|
9
|
+
|
|
10
|
+
var _linkingCommon = require("@atlaskit/linking-common");
|
|
11
|
+
|
|
12
|
+
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
13
|
+
|
|
14
|
+
var _icon = require("../icon");
|
|
15
|
+
|
|
16
|
+
var extractPreviewAction = function extractPreviewAction(response) {
|
|
17
|
+
var _extractPreviewData;
|
|
18
|
+
|
|
19
|
+
var data = response.data;
|
|
20
|
+
var src = (_extractPreviewData = (0, _linkingCommon.extractPreview)(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
21
|
+
|
|
22
|
+
if (src) {
|
|
23
|
+
var _extractProvider;
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
downloadUrl: (0, _detail.extractDownloadUrl)(data),
|
|
27
|
+
providerName: (_extractProvider = (0, _extractors.extractProvider)(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text,
|
|
28
|
+
src: src,
|
|
29
|
+
title: (0, _extractors.extractTitle)(data),
|
|
30
|
+
linkIcon: (0, _icon.extractLinkIcon)(response),
|
|
31
|
+
url: (0, _extractors.extractLink)(data)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.extractPreviewAction = extractPreviewAction;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractViewAction = void 0;
|
|
7
|
+
|
|
8
|
+
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
9
|
+
|
|
10
|
+
var _extractActions = require("../../common/actions/extractActions");
|
|
11
|
+
|
|
12
|
+
var extractViewAction = function extractViewAction(data) {
|
|
13
|
+
var viewActionExists = (0, _extractActions.getActionsFromJsonLd)(data).find(function (action) {
|
|
14
|
+
return action['@type'] === 'ViewAction';
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (viewActionExists) {
|
|
18
|
+
return {
|
|
19
|
+
viewUrl: (0, _extractors.extractLink)(data)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.extractViewAction = extractViewAction;
|
|
@@ -27,6 +27,12 @@ var _extractPreview = _interopRequireDefault(require("./extract-preview"));
|
|
|
27
27
|
|
|
28
28
|
var _latestCommit = require("./latest-commit");
|
|
29
29
|
|
|
30
|
+
var _extractPreviewAction = require("./actions/extract-preview-action");
|
|
31
|
+
|
|
32
|
+
var _extractDownloadAction = require("./actions/extract-download-action");
|
|
33
|
+
|
|
34
|
+
var _extractViewAction = require("./actions/extract-view-action");
|
|
35
|
+
|
|
30
36
|
var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
|
|
31
37
|
if (!response) {
|
|
32
38
|
return undefined;
|
|
@@ -45,6 +51,9 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
|
|
|
45
51
|
createdBy: (0, _utils.extractCreatedBy)(data),
|
|
46
52
|
createdOn: (0, _extractors.extractDateCreated)(data),
|
|
47
53
|
dueOn: (0, _utils.extractDueOn)(data),
|
|
54
|
+
previewAction: (0, _extractPreviewAction.extractPreviewAction)(response),
|
|
55
|
+
viewAction: (0, _extractViewAction.extractViewAction)(data),
|
|
56
|
+
downloadAction: (0, _extractDownloadAction.extractDownloadAction)(data),
|
|
48
57
|
latestCommit: (0, _latestCommit.extractLatestCommit)(data),
|
|
49
58
|
linkIcon: (0, _icon.extractLinkIcon)(response, renderers),
|
|
50
59
|
modifiedBy: (0, _utils.extractModifiedBy)(data),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useFlexibleUiContext = exports.FlexibleUiContext = void 0;
|
|
6
|
+
exports.useFlexibleUiContext = exports.useFlexibleUiAnalyticsContext = exports.FlexibleUiContext = exports.FlexibleUiAnalyticsContext = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
@@ -17,5 +17,18 @@ exports.FlexibleUiContext = FlexibleUiContext;
|
|
|
17
17
|
var useFlexibleUiContext = function useFlexibleUiContext() {
|
|
18
18
|
return (0, _react.useContext)(FlexibleUiContext);
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* This provides the data that will be used by Smart Links Flexible UI to populate it's
|
|
22
|
+
* underlying elements.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.useFlexibleUiContext = useFlexibleUiContext;
|
|
27
|
+
var FlexibleUiAnalyticsContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
28
|
+
exports.FlexibleUiAnalyticsContext = FlexibleUiAnalyticsContext;
|
|
29
|
+
|
|
30
|
+
var useFlexibleUiAnalyticsContext = function useFlexibleUiAnalyticsContext() {
|
|
31
|
+
return (0, _react.useContext)(FlexibleUiAnalyticsContext);
|
|
32
|
+
};
|
|
20
33
|
|
|
21
|
-
exports.
|
|
34
|
+
exports.useFlexibleUiAnalyticsContext = useFlexibleUiAnalyticsContext;
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
|
+
|
|
20
|
+
var _index = _interopRequireDefault(require("../index"));
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
|
|
26
|
+
var DownloadAction = function DownloadAction(props) {
|
|
27
|
+
var appearance = props.appearance,
|
|
28
|
+
asDropDownItem = props.asDropDownItem,
|
|
29
|
+
downloadUrl = props.downloadUrl,
|
|
30
|
+
_onClick = props.onClick,
|
|
31
|
+
testId = props.testId,
|
|
32
|
+
url = props.url;
|
|
33
|
+
|
|
34
|
+
if (downloadUrl && url) {
|
|
35
|
+
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
downloadFunction({
|
|
38
|
+
url: downloadUrl
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (_onClick) {
|
|
42
|
+
_onClick();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, (0, _extends2.default)({}, action, {
|
|
48
|
+
appearance: appearance,
|
|
49
|
+
asDropDownItem: asDropDownItem,
|
|
50
|
+
testId: testId
|
|
51
|
+
}));
|
|
52
|
+
} else {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function downloadFunction(_x) {
|
|
58
|
+
return _downloadFunction.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _downloadFunction() {
|
|
62
|
+
_downloadFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
63
|
+
var url, isIE11, isSafari, iframeName, link, iframe;
|
|
64
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
65
|
+
while (1) {
|
|
66
|
+
switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
url = _ref.url;
|
|
69
|
+
|
|
70
|
+
if (url) {
|
|
71
|
+
_context.next = 3;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return _context.abrupt("return");
|
|
76
|
+
|
|
77
|
+
case 3:
|
|
78
|
+
isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
|
|
79
|
+
isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
80
|
+
iframeName = 'media-download-iframe';
|
|
81
|
+
link = document.createElement('a');
|
|
82
|
+
iframe = document.getElementById(iframeName);
|
|
83
|
+
|
|
84
|
+
if (!iframe) {
|
|
85
|
+
iframe = document.createElement('iframe');
|
|
86
|
+
iframe.style.display = 'none';
|
|
87
|
+
iframe.id = iframeName;
|
|
88
|
+
iframe.name = iframeName;
|
|
89
|
+
document.body.appendChild(iframe);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
link.href = url;
|
|
93
|
+
link.download = url;
|
|
94
|
+
link.target = isIE11 || isSafari ? '_blank' : iframeName;
|
|
95
|
+
document.body.appendChild(link);
|
|
96
|
+
link.click();
|
|
97
|
+
document.body.removeChild(link);
|
|
98
|
+
|
|
99
|
+
case 15:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context.stop();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
}));
|
|
106
|
+
return _downloadFunction.apply(this, arguments);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var _default = DownloadAction;
|
|
110
|
+
exports.default = _default;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
exports.previewFunction = previewFunction;
|
|
12
|
+
|
|
13
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
+
|
|
15
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
|
+
|
|
17
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
+
|
|
19
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
20
|
+
|
|
21
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
22
|
+
|
|
23
|
+
var _react = _interopRequireDefault(require("react"));
|
|
24
|
+
|
|
25
|
+
var _index = _interopRequireDefault(require("../index"));
|
|
26
|
+
|
|
27
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
28
|
+
|
|
29
|
+
var _reactIntlNext = require("react-intl-next");
|
|
30
|
+
|
|
31
|
+
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
|
|
32
|
+
|
|
33
|
+
var _state = require("../../../../../../state");
|
|
34
|
+
|
|
35
|
+
var _icon = _interopRequireDefault(require("../../../elements/icon"));
|
|
36
|
+
|
|
37
|
+
var _excluded = ["popupMountPointId"];
|
|
38
|
+
|
|
39
|
+
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); }
|
|
40
|
+
|
|
41
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
|
+
|
|
43
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
44
|
+
|
|
45
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
46
|
+
|
|
47
|
+
var PreviewAction = function PreviewAction(props) {
|
|
48
|
+
var appearance = props.appearance,
|
|
49
|
+
asDropDownItem = props.asDropDownItem,
|
|
50
|
+
testId = props.testId,
|
|
51
|
+
_onClick = props.onClick,
|
|
52
|
+
linkIcon = props.linkIcon,
|
|
53
|
+
src = props.src,
|
|
54
|
+
url = props.url,
|
|
55
|
+
title = props.title,
|
|
56
|
+
providerName = props.providerName,
|
|
57
|
+
downloadUrl = props.downloadUrl;
|
|
58
|
+
var defaultAnalytics = (0, _state.useSmartLinkAnalytics)(url, function () {});
|
|
59
|
+
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)() || defaultAnalytics;
|
|
60
|
+
var EmbedIcon = {
|
|
61
|
+
icon: /*#__PURE__*/_react.default.createElement(_icon.default, linkIcon),
|
|
62
|
+
isFlexibleUi: true
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (src && url) {
|
|
66
|
+
var embedModal = function embedModal() {
|
|
67
|
+
return previewFunction({
|
|
68
|
+
popupMountPointId: 'twp-editor-preview-iframe',
|
|
69
|
+
showModal: true,
|
|
70
|
+
iframeName: 'twp-editor-preview-iframe',
|
|
71
|
+
onClose: function onClose() {},
|
|
72
|
+
download: downloadUrl,
|
|
73
|
+
icon: EmbedIcon,
|
|
74
|
+
providerName: providerName || 'Preview',
|
|
75
|
+
src: src,
|
|
76
|
+
title: title,
|
|
77
|
+
url: url,
|
|
78
|
+
analytics: analytics,
|
|
79
|
+
origin: 'smartLinkCard'
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
84
|
+
onClick: function onClick() {
|
|
85
|
+
embedModal();
|
|
86
|
+
|
|
87
|
+
if (_onClick) {
|
|
88
|
+
_onClick();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, (0, _extends2.default)({}, action, {
|
|
94
|
+
appearance: appearance,
|
|
95
|
+
asDropDownItem: asDropDownItem,
|
|
96
|
+
testId: testId
|
|
97
|
+
}));
|
|
98
|
+
} else {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/*
|
|
103
|
+
Explanatory note:
|
|
104
|
+
Actions don't have access to the react tree of whatever is rendered them
|
|
105
|
+
(and this concept is fraught inside editor anyway) so we want to ensure
|
|
106
|
+
it is mounting to a new unique place. This function manages that, including
|
|
107
|
+
creating an element if it doesn't exist, as well as tidying up the react tree
|
|
108
|
+
(but not the element) upon closing the modal.
|
|
109
|
+
|
|
110
|
+
This may strike you as really uncomfortable as you read it, so I wanted to note
|
|
111
|
+
that a) this was discussed and agreed upon, and b) it's definitely odd, and if
|
|
112
|
+
you find an elegant solution around this, you should definitely feel free to
|
|
113
|
+
refactor it.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
function previewFunction(_x) {
|
|
118
|
+
return _previewFunction.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _previewFunction() {
|
|
122
|
+
_previewFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
123
|
+
var popupMountPointId, rest, popupMountPoint, Modal;
|
|
124
|
+
return _regenerator.default.wrap(function _callee$(_context2) {
|
|
125
|
+
while (1) {
|
|
126
|
+
switch (_context2.prev = _context2.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
popupMountPointId = _ref.popupMountPointId, rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
129
|
+
popupMountPoint = document.getElementById(popupMountPointId);
|
|
130
|
+
|
|
131
|
+
if (!popupMountPoint) {
|
|
132
|
+
popupMountPoint = document.createElement('div');
|
|
133
|
+
popupMountPoint.id = popupMountPointId;
|
|
134
|
+
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
135
|
+
document.body.appendChild(popupMountPoint);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_context2.next = 5;
|
|
139
|
+
return Promise.resolve().then(function () {
|
|
140
|
+
return _interopRequireWildcard(require('../../../../../EmbedModal'));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
case 5:
|
|
144
|
+
Modal = _context2.sent;
|
|
145
|
+
|
|
146
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
147
|
+
locale: "en"
|
|
148
|
+
}, /*#__PURE__*/_react.default.createElement(Modal.default, (0, _extends2.default)({}, rest, {
|
|
149
|
+
onClose: function onClose(_context) {
|
|
150
|
+
if (popupMountPoint) {
|
|
151
|
+
_reactDom.default.unmountComponentAtNode(popupMountPoint);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}))), popupMountPoint);
|
|
155
|
+
|
|
156
|
+
case 7:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context2.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee);
|
|
162
|
+
}));
|
|
163
|
+
return _previewFunction.apply(this, arguments);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var _default = PreviewAction;
|
|
167
|
+
exports.default = _default;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
exports.viewFunction = viewFunction;
|
|
10
|
+
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
13
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
+
|
|
15
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
+
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
+
|
|
19
|
+
var _react = _interopRequireDefault(require("react"));
|
|
20
|
+
|
|
21
|
+
var _index = _interopRequireDefault(require("../index"));
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
+
|
|
27
|
+
var ViewAction = function ViewAction(props) {
|
|
28
|
+
var appearance = props.appearance,
|
|
29
|
+
asDropDownItem = props.asDropDownItem,
|
|
30
|
+
testId = props.testId,
|
|
31
|
+
_onClick = props.onClick,
|
|
32
|
+
viewUrl = props.viewUrl,
|
|
33
|
+
url = props.url;
|
|
34
|
+
|
|
35
|
+
if (viewUrl && url) {
|
|
36
|
+
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
viewFunction({
|
|
39
|
+
url: viewUrl
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (_onClick) {
|
|
43
|
+
_onClick();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, (0, _extends2.default)({}, action, {
|
|
49
|
+
appearance: appearance,
|
|
50
|
+
asDropDownItem: asDropDownItem,
|
|
51
|
+
testId: testId
|
|
52
|
+
}));
|
|
53
|
+
} else {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function viewFunction(_x) {
|
|
59
|
+
return _viewFunction.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _viewFunction() {
|
|
63
|
+
_viewFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
64
|
+
var url;
|
|
65
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
66
|
+
while (1) {
|
|
67
|
+
switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
url = _ref.url;
|
|
70
|
+
|
|
71
|
+
if (url) {
|
|
72
|
+
_context.next = 3;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return _context.abrupt("return");
|
|
77
|
+
|
|
78
|
+
case 3:
|
|
79
|
+
window.open(url, '_blank', 'noopener=yes');
|
|
80
|
+
|
|
81
|
+
case 4:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context.stop();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, _callee);
|
|
87
|
+
}));
|
|
88
|
+
return _viewFunction.apply(this, arguments);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var _default = ViewAction;
|
|
92
|
+
exports.default = _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.EditAction = exports.DeleteAction = exports.CustomAction = void 0;
|
|
6
|
+
exports.ViewAction = exports.PreviewAction = exports.EditAction = exports.DownloadAction = exports.DeleteAction = exports.CustomAction = void 0;
|
|
7
7
|
|
|
8
8
|
var _constants = require("../../../../constants");
|
|
9
9
|
|
|
@@ -27,12 +27,36 @@ var DeleteAction = (0, _utils.createUIAction)(_constants.ActionName.DeleteAction
|
|
|
27
27
|
|
|
28
28
|
exports.DeleteAction = DeleteAction;
|
|
29
29
|
var EditAction = (0, _utils.createUIAction)(_constants.ActionName.EditAction);
|
|
30
|
+
/**
|
|
31
|
+
* Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
|
|
32
|
+
* to the text 'Preview' inside the button.
|
|
33
|
+
* @see Action
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
exports.EditAction = EditAction;
|
|
37
|
+
var PreviewAction = (0, _utils.createDataAction)(_constants.ActionName.PreviewAction);
|
|
38
|
+
/**
|
|
39
|
+
* Creates a ViewAction component. Accepts default ViewActionProps, and defaults
|
|
40
|
+
* to the text 'View' inside the button.
|
|
41
|
+
* @see Action
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
exports.PreviewAction = PreviewAction;
|
|
45
|
+
var ViewAction = (0, _utils.createDataAction)(_constants.ActionName.ViewAction);
|
|
46
|
+
/**
|
|
47
|
+
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
48
|
+
* to the text 'Download' inside the button.
|
|
49
|
+
* @see Action
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
exports.ViewAction = ViewAction;
|
|
53
|
+
var DownloadAction = (0, _utils.createDataAction)(_constants.ActionName.DownloadAction);
|
|
30
54
|
/**
|
|
31
55
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
32
56
|
* your own icon or text.
|
|
33
57
|
* @see Action
|
|
34
58
|
*/
|
|
35
59
|
|
|
36
|
-
exports.
|
|
60
|
+
exports.DownloadAction = DownloadAction;
|
|
37
61
|
var CustomAction = (0, _utils.createUIAction)(_constants.ActionName.CustomAction);
|
|
38
62
|
exports.CustomAction = CustomAction;
|