@atlaskit/smart-card 25.9.0 → 25.9.2
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 +13 -0
- package/dist/cjs/extractors/flexible/extract-state.js +4 -1
- package/dist/cjs/state/actions/index.js +11 -27
- package/dist/cjs/state/hooks/use-resolve/index.js +12 -21
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +3 -12
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/cjs/view/EmbedModal/utils.js +111 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -83
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/index.js +24 -18
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +35 -5
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +6 -4
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +3 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +4 -11
- package/dist/es2019/extractors/flexible/extract-state.js +4 -1
- package/dist/es2019/state/actions/index.js +12 -32
- package/dist/es2019/state/hooks/use-resolve/index.js +12 -21
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +2 -8
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/es2019/view/EmbedModal/utils.js +77 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -56
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/index.js +11 -7
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +35 -5
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +9 -1
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +11 -4
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +3 -10
- package/dist/esm/extractors/flexible/extract-state.js +4 -1
- package/dist/esm/state/actions/index.js +11 -27
- package/dist/esm/state/hooks/use-resolve/index.js +12 -21
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +2 -10
- package/dist/esm/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/esm/view/EmbedModal/utils.js +98 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -78
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/index.js +24 -18
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +37 -5
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +4 -3
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +3 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +4 -11
- package/dist/types/state/hooks/use-invoke/types.d.ts +5 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -1
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -1
- package/dist/types/view/EmbedModal/utils.d.ts +10 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.d.ts +18 -0
- package/package.json +1 -2
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +0 -47
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +0 -35
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +0 -36
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +0 -9
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
+
var _excluded = ["popupMountPointId", "onClose"];
|
|
6
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import ReactDOM from 'react-dom';
|
|
9
|
+
import { IntlProvider } from 'react-intl-next';
|
|
10
|
+
import Icon from '../FlexibleCard/components/elements/icon';
|
|
11
|
+
export var openPreviewModal = function openPreviewModal(_ref) {
|
|
12
|
+
var analytics = _ref.analytics,
|
|
13
|
+
download = _ref.downloadUrl,
|
|
14
|
+
isSupportTheming = _ref.isSupportTheming,
|
|
15
|
+
linkIcon = _ref.linkIcon,
|
|
16
|
+
_ref$onClose = _ref.onClose,
|
|
17
|
+
onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
|
|
18
|
+
providerName = _ref.providerName,
|
|
19
|
+
src = _ref.src,
|
|
20
|
+
title = _ref.title,
|
|
21
|
+
url = _ref.url;
|
|
22
|
+
var EmbedIcon = {
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(Icon, linkIcon),
|
|
24
|
+
isFlexibleUi: true
|
|
25
|
+
};
|
|
26
|
+
return previewFunction({
|
|
27
|
+
popupMountPointId: 'twp-editor-preview-iframe',
|
|
28
|
+
showModal: true,
|
|
29
|
+
iframeName: 'twp-editor-preview-iframe',
|
|
30
|
+
onClose: onClose,
|
|
31
|
+
download: download,
|
|
32
|
+
icon: EmbedIcon,
|
|
33
|
+
providerName: providerName || 'Preview',
|
|
34
|
+
src: src,
|
|
35
|
+
title: title,
|
|
36
|
+
url: url,
|
|
37
|
+
analytics: analytics,
|
|
38
|
+
origin: 'smartLinkCard',
|
|
39
|
+
isSupportTheming: isSupportTheming
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
Explanatory note:
|
|
45
|
+
Actions don't have access to the react tree of whatever is rendered them
|
|
46
|
+
(and this concept is fraught inside editor anyway) so we want to ensure
|
|
47
|
+
it is mounting to a new unique place. This function manages that, including
|
|
48
|
+
creating an element if it doesn't exist, as well as tidying up the react tree
|
|
49
|
+
(but not the element) upon closing the modal.
|
|
50
|
+
|
|
51
|
+
This may strike you as really uncomfortable as you read it, so I wanted to note
|
|
52
|
+
that a) this was discussed and agreed upon, and b) it's definitely odd, and if
|
|
53
|
+
you find an elegant solution around this, you should definitely feel free to
|
|
54
|
+
refactor it.
|
|
55
|
+
*/
|
|
56
|
+
export function previewFunction(_x) {
|
|
57
|
+
return _previewFunction.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
function _previewFunction() {
|
|
60
|
+
_previewFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
61
|
+
var popupMountPointId, onEmbedClose, rest, popupMountPoint, Modal;
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
63
|
+
while (1) {
|
|
64
|
+
switch (_context2.prev = _context2.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
popupMountPointId = _ref2.popupMountPointId, onEmbedClose = _ref2.onClose, rest = _objectWithoutProperties(_ref2, _excluded);
|
|
67
|
+
popupMountPoint = document.getElementById(popupMountPointId);
|
|
68
|
+
if (!popupMountPoint) {
|
|
69
|
+
popupMountPoint = document.createElement('div');
|
|
70
|
+
popupMountPoint.id = popupMountPointId;
|
|
71
|
+
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
72
|
+
document.body.appendChild(popupMountPoint);
|
|
73
|
+
}
|
|
74
|
+
_context2.next = 5;
|
|
75
|
+
return import('./index');
|
|
76
|
+
case 5:
|
|
77
|
+
Modal = _context2.sent;
|
|
78
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
79
|
+
locale: "en"
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Modal.default, _extends({}, rest, {
|
|
81
|
+
onClose: function onClose(_context) {
|
|
82
|
+
if (popupMountPoint) {
|
|
83
|
+
ReactDOM.unmountComponentAtNode(popupMountPoint);
|
|
84
|
+
}
|
|
85
|
+
if (onEmbedClose) {
|
|
86
|
+
onEmbedClose(_context);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}))), popupMountPoint);
|
|
90
|
+
case 7:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context2.stop();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}));
|
|
97
|
+
return _previewFunction.apply(this, arguments);
|
|
98
|
+
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
5
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
var _excluded = ["popupMountPointId"];
|
|
7
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
8
3
|
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; }
|
|
9
4
|
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) { _defineProperty(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; }
|
|
10
5
|
import React from 'react';
|
|
11
6
|
import Action from '../index';
|
|
12
|
-
import ReactDOM from 'react-dom';
|
|
13
|
-
import { IntlProvider } from 'react-intl-next';
|
|
14
7
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
15
8
|
import { useSmartLinkAnalytics } from '../../../../../../state';
|
|
16
|
-
import
|
|
9
|
+
import { openPreviewModal } from '../../../../../EmbedModal/utils';
|
|
17
10
|
var PreviewAction = function PreviewAction(props) {
|
|
18
11
|
var appearance = props.appearance,
|
|
19
12
|
asDropDownItem = props.asDropDownItem,
|
|
@@ -28,26 +21,16 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
28
21
|
isSupportTheming = props.isSupportTheming;
|
|
29
22
|
var defaultAnalytics = useSmartLinkAnalytics(url, function () {});
|
|
30
23
|
var analytics = useFlexibleUiAnalyticsContext() || defaultAnalytics;
|
|
31
|
-
var EmbedIcon = {
|
|
32
|
-
icon: /*#__PURE__*/React.createElement(Icon, linkIcon),
|
|
33
|
-
isFlexibleUi: true
|
|
34
|
-
};
|
|
35
24
|
if (src && url) {
|
|
36
25
|
var embedModal = function embedModal() {
|
|
37
|
-
return
|
|
38
|
-
popupMountPointId: 'twp-editor-preview-iframe',
|
|
39
|
-
showModal: true,
|
|
40
|
-
iframeName: 'twp-editor-preview-iframe',
|
|
41
|
-
onClose: function onClose() {},
|
|
42
|
-
download: downloadUrl,
|
|
43
|
-
icon: EmbedIcon,
|
|
44
|
-
providerName: providerName || 'Preview',
|
|
45
|
-
src: src,
|
|
26
|
+
return openPreviewModal({
|
|
46
27
|
title: title,
|
|
47
|
-
|
|
28
|
+
providerName: providerName,
|
|
29
|
+
downloadUrl: downloadUrl,
|
|
30
|
+
isSupportTheming: isSupportTheming,
|
|
48
31
|
analytics: analytics,
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
linkIcon: linkIcon,
|
|
33
|
+
src: src
|
|
51
34
|
});
|
|
52
35
|
};
|
|
53
36
|
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -67,58 +50,4 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
67
50
|
return null;
|
|
68
51
|
}
|
|
69
52
|
};
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
Explanatory note:
|
|
73
|
-
Actions don't have access to the react tree of whatever is rendered them
|
|
74
|
-
(and this concept is fraught inside editor anyway) so we want to ensure
|
|
75
|
-
it is mounting to a new unique place. This function manages that, including
|
|
76
|
-
creating an element if it doesn't exist, as well as tidying up the react tree
|
|
77
|
-
(but not the element) upon closing the modal.
|
|
78
|
-
|
|
79
|
-
This may strike you as really uncomfortable as you read it, so I wanted to note
|
|
80
|
-
that a) this was discussed and agreed upon, and b) it's definitely odd, and if
|
|
81
|
-
you find an elegant solution around this, you should definitely feel free to
|
|
82
|
-
refactor it.
|
|
83
|
-
*/
|
|
84
|
-
export function previewFunction(_x) {
|
|
85
|
-
return _previewFunction.apply(this, arguments);
|
|
86
|
-
}
|
|
87
|
-
function _previewFunction() {
|
|
88
|
-
_previewFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
89
|
-
var popupMountPointId, rest, popupMountPoint, Modal;
|
|
90
|
-
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
91
|
-
while (1) {
|
|
92
|
-
switch (_context2.prev = _context2.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
popupMountPointId = _ref.popupMountPointId, rest = _objectWithoutProperties(_ref, _excluded);
|
|
95
|
-
popupMountPoint = document.getElementById(popupMountPointId);
|
|
96
|
-
if (!popupMountPoint) {
|
|
97
|
-
popupMountPoint = document.createElement('div');
|
|
98
|
-
popupMountPoint.id = popupMountPointId;
|
|
99
|
-
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
100
|
-
document.body.appendChild(popupMountPoint);
|
|
101
|
-
}
|
|
102
|
-
_context2.next = 5;
|
|
103
|
-
return import('../../../../../EmbedModal');
|
|
104
|
-
case 5:
|
|
105
|
-
Modal = _context2.sent;
|
|
106
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
107
|
-
locale: "en"
|
|
108
|
-
}, /*#__PURE__*/React.createElement(Modal.default, _extends({}, rest, {
|
|
109
|
-
onClose: function onClose(_context) {
|
|
110
|
-
if (popupMountPoint) {
|
|
111
|
-
ReactDOM.unmountComponentAtNode(popupMountPoint);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}))), popupMountPoint);
|
|
115
|
-
case 7:
|
|
116
|
-
case "end":
|
|
117
|
-
return _context2.stop();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}, _callee);
|
|
121
|
-
}));
|
|
122
|
-
return _previewFunction.apply(this, arguments);
|
|
123
|
-
}
|
|
124
53
|
export default PreviewAction;
|
|
@@ -28,6 +28,7 @@ var isInvokeCustomError = function isInvokeCustomError(err) {
|
|
|
28
28
|
return err.message !== undefined && err.errorCode !== undefined;
|
|
29
29
|
};
|
|
30
30
|
var LozengeAction = function LozengeAction(_ref) {
|
|
31
|
+
var _action$update;
|
|
31
32
|
var action = _ref.action,
|
|
32
33
|
appearance = _ref.appearance,
|
|
33
34
|
_ref$testId = _ref.testId,
|
|
@@ -56,8 +57,12 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
56
57
|
setErrorMessage = _useState10[1];
|
|
57
58
|
var invoke = useInvoke();
|
|
58
59
|
var reload = useResolve();
|
|
60
|
+
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
61
|
+
url = _ref2.url,
|
|
62
|
+
linkId = _ref2.id,
|
|
63
|
+
previewData = _ref2.previewData;
|
|
59
64
|
var handleOpenChange = useCallback( /*#__PURE__*/function () {
|
|
60
|
-
var
|
|
65
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
61
66
|
var responseItems, validItems;
|
|
62
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
68
|
while (1) {
|
|
@@ -104,7 +109,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
104
109
|
}, _callee, null, [[2, 13, 17, 20]]);
|
|
105
110
|
}));
|
|
106
111
|
return function (_x) {
|
|
107
|
-
return
|
|
112
|
+
return _ref3.apply(this, arguments);
|
|
108
113
|
};
|
|
109
114
|
}(), [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
110
115
|
var trigger = useCallback(function (props) {
|
|
@@ -115,8 +120,8 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
115
120
|
}));
|
|
116
121
|
}, [appearance, testId, text]);
|
|
117
122
|
var handleItemClick = useCallback( /*#__PURE__*/function () {
|
|
118
|
-
var
|
|
119
|
-
var updateAction, request
|
|
123
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id) {
|
|
124
|
+
var updateAction, request;
|
|
120
125
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
121
126
|
while (1) {
|
|
122
127
|
switch (_context2.prev = _context2.next) {
|
|
@@ -124,7 +129,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
124
129
|
_context2.prev = 0;
|
|
125
130
|
updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
126
131
|
if (!(updateAction && id)) {
|
|
127
|
-
_context2.next =
|
|
132
|
+
_context2.next = 14;
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
130
135
|
setIsLoading(true);
|
|
@@ -136,18 +141,17 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
136
141
|
setIsLoaded(false);
|
|
137
142
|
setIsOpen(false);
|
|
138
143
|
setItems([]);
|
|
139
|
-
_ref4 = updateAction.details || {}, url = _ref4.url, linkId = _ref4.id;
|
|
140
144
|
if (!url) {
|
|
141
|
-
_context2.next =
|
|
145
|
+
_context2.next = 14;
|
|
142
146
|
break;
|
|
143
147
|
}
|
|
144
|
-
_context2.next =
|
|
148
|
+
_context2.next = 14;
|
|
145
149
|
return reload(url, true, undefined, linkId);
|
|
146
|
-
case
|
|
147
|
-
_context2.next =
|
|
150
|
+
case 14:
|
|
151
|
+
_context2.next = 20;
|
|
148
152
|
break;
|
|
149
|
-
case
|
|
150
|
-
_context2.prev =
|
|
153
|
+
case 16:
|
|
154
|
+
_context2.prev = 16;
|
|
151
155
|
_context2.t0 = _context2["catch"](0);
|
|
152
156
|
setIsLoading(false);
|
|
153
157
|
if (isInvokeCustomError(_context2.t0)) {
|
|
@@ -155,22 +159,24 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
155
159
|
} else {
|
|
156
160
|
setErrorMessage(LozengeActionErrorMessages.updateFailed);
|
|
157
161
|
}
|
|
158
|
-
case
|
|
162
|
+
case 20:
|
|
159
163
|
case "end":
|
|
160
164
|
return _context2.stop();
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
|
-
}, _callee2, null, [[0,
|
|
167
|
+
}, _callee2, null, [[0, 16]]);
|
|
164
168
|
}));
|
|
165
169
|
return function (_x2) {
|
|
166
|
-
return
|
|
170
|
+
return _ref4.apply(this, arguments);
|
|
167
171
|
};
|
|
168
|
-
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
|
|
172
|
+
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
|
169
173
|
var dropdownItemGroup = useMemo(function () {
|
|
170
174
|
if (errorMessage) {
|
|
171
175
|
return jsx(LozengeActionError, {
|
|
172
176
|
errorMessage: errorMessage,
|
|
173
|
-
testId: testId
|
|
177
|
+
testId: testId,
|
|
178
|
+
url: url,
|
|
179
|
+
previewData: previewData
|
|
174
180
|
});
|
|
175
181
|
}
|
|
176
182
|
if (items && items.length > 0) {
|
|
@@ -185,7 +191,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
185
191
|
}));
|
|
186
192
|
})));
|
|
187
193
|
}
|
|
188
|
-
}, [errorMessage, handleItemClick, items, testId]);
|
|
194
|
+
}, [errorMessage, handleItemClick, items, previewData, testId, url]);
|
|
189
195
|
return jsx(DropdownMenu, {
|
|
190
196
|
isLoading: isLoading,
|
|
191
197
|
isOpen: isOpen,
|
package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js
CHANGED
|
@@ -1,17 +1,43 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { jsx } from '@emotion/react';
|
|
3
|
-
import { Fragment, useMemo } from 'react';
|
|
6
|
+
import { Fragment, useMemo, useCallback } from 'react';
|
|
7
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
4
8
|
import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
5
9
|
import { R50, R500 } from '@atlaskit/theme/colors';
|
|
6
10
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
7
|
-
import { dropdownItemGroupStyles, contentStyles, textStyles } from './styled';
|
|
11
|
+
import { dropdownItemGroupStyles, contentStyles, linkStyles, textStyles } from './styled';
|
|
8
12
|
import { getFormattedMessage } from '../../../utils';
|
|
13
|
+
import { messages } from '../../../../../../messages';
|
|
14
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
15
|
+
import { openPreviewModal } from '../../../../../EmbedModal/utils';
|
|
16
|
+
import useResolve from '../../../../../../state/hooks/use-resolve';
|
|
9
17
|
var MAX_LINE_NUMBER = 8;
|
|
10
18
|
var LozengeActionError = function LozengeActionError(_ref) {
|
|
11
19
|
var errorMessage = _ref.errorMessage,
|
|
12
20
|
testId = _ref.testId,
|
|
13
21
|
_ref$maxLineNumber = _ref.maxLineNumber,
|
|
14
|
-
maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber
|
|
22
|
+
maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber,
|
|
23
|
+
url = _ref.url,
|
|
24
|
+
previewData = _ref.previewData;
|
|
25
|
+
var reload = useResolve();
|
|
26
|
+
var analytics = useFlexibleUiAnalyticsContext();
|
|
27
|
+
var isPreviewAvailable = previewData && previewData.src !== undefined;
|
|
28
|
+
var handlePreviewClose = useCallback(function () {
|
|
29
|
+
if (url) {
|
|
30
|
+
reload(url, true);
|
|
31
|
+
}
|
|
32
|
+
}, [reload, url]);
|
|
33
|
+
var handlePreviewOpen = useCallback(function () {
|
|
34
|
+
if (isPreviewAvailable) {
|
|
35
|
+
return openPreviewModal(_objectSpread(_objectSpread({}, previewData), {}, {
|
|
36
|
+
analytics: analytics,
|
|
37
|
+
onClose: handlePreviewClose
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}, [analytics, handlePreviewClose, isPreviewAvailable, previewData]);
|
|
15
41
|
var content = useMemo(function () {
|
|
16
42
|
return jsx(Fragment, null, jsx("div", {
|
|
17
43
|
css: contentStyles
|
|
@@ -24,8 +50,14 @@ var LozengeActionError = function LozengeActionError(_ref) {
|
|
|
24
50
|
}), jsx("span", {
|
|
25
51
|
css: textStyles(maxLineNumber),
|
|
26
52
|
"data-testid": "".concat(testId, "-error-message")
|
|
27
|
-
}, typeof errorMessage === 'string' ? errorMessage : getFormattedMessage(errorMessage)))
|
|
28
|
-
|
|
53
|
+
}, typeof errorMessage === 'string' ? errorMessage : getFormattedMessage(errorMessage))), isPreviewAvailable ? jsx("div", {
|
|
54
|
+
css: linkStyles
|
|
55
|
+
}, jsx("a", {
|
|
56
|
+
target: "_blank",
|
|
57
|
+
"data-testid": "".concat(testId, "-open-embed"),
|
|
58
|
+
onClick: handlePreviewOpen
|
|
59
|
+
}, jsx(FormattedMessage, messages.open_issue_in_jira))) : null);
|
|
60
|
+
}, [errorMessage, handlePreviewOpen, isPreviewAvailable, maxLineNumber, testId]);
|
|
29
61
|
return jsx("span", {
|
|
30
62
|
css: dropdownItemGroupStyles,
|
|
31
63
|
"data-testid": "".concat(testId, "-error-item-group")
|
package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { N800 } from '@atlaskit/theme/colors';
|
|
5
5
|
import { getTruncateStyles } from '../../../utils';
|
|
6
6
|
export var dropdownItemGroupStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n width: 220px;\n\n &:hover {\n background-color: inherit;\n cursor: default;\n }\n }\n"])));
|
|
7
7
|
var sharedBlockStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n gap: 0.5rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n flex-direction: row;\n align-items: center;\n"])));
|
|
8
|
-
export var contentStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n\n margin-top:
|
|
8
|
+
export var contentStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n\n margin-top: ", ";\n align-items: flex-start;\n\n > span,\n > div {\n &[data-smart-element-text] {\n font-size: 0.875rem;\n color: ", ";\n }\n }\n"])), sharedBlockStyles, "var(--ds-space-025, 2px)", "var(--ds-text, ".concat(N800, ")"));
|
|
9
|
+
export var linkStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n\n font-size: 0.875rem;\n margin-top: 10px;\n margin-left: ", ";\n margin-bottom: ", ";\n"])), sharedBlockStyles, "var(--ds-space-400, 32px)", "var(--ds-space-025, 2px)");
|
|
9
10
|
export var textStyles = function textStyles(maxLines) {
|
|
10
|
-
return css(
|
|
11
|
+
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n line-height: 1rem;\n white-space: normal;\n ", ";\n"])), getTruncateStyles(maxLines));
|
|
11
12
|
};
|
|
@@ -15,7 +15,9 @@ var containerStyles = css(_templateObject || (_templateObject = _taggedTemplateL
|
|
|
15
15
|
var getThemeStyles = function getThemeStyles(theme) {
|
|
16
16
|
switch (theme) {
|
|
17
17
|
case SmartLinkInternalTheme.Grey:
|
|
18
|
-
|
|
18
|
+
// We are being specifc with the CSS selectors to ensure that Confluence overrides
|
|
19
|
+
// do not affect our internal Smart Card styles
|
|
20
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n a& {\n color: ", ";\n &:active,\n &:visited,\n &:focus,\n &:hover {\n color: ", ";\n text-decoration: underline;\n }\n font-size: 12px;\n }\n "])), "var(--ds-text-subtlest, #626F86)", "var(--ds-text-subtlest, #626F86)");
|
|
19
21
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
20
22
|
case SmartLinkTheme.Black:
|
|
21
23
|
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n :active {\n color: ", ";\n }\n :hover {\n color: ", ";\n text-decoration: underline;\n }\n "])), tokens.blackLink, tokens.blackLinkPressed, tokens.blackLink);
|
|
@@ -10,11 +10,9 @@ import { useSmartCardState as useLinkState } from '../../../state/store';
|
|
|
10
10
|
import HoverCardContent from '../components/HoverCardContent';
|
|
11
11
|
import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
|
|
12
12
|
import { CardDisplay } from '../../../constants';
|
|
13
|
-
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
14
13
|
export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
15
14
|
var children = _ref.children,
|
|
16
15
|
url = _ref.url,
|
|
17
|
-
id = _ref.id,
|
|
18
16
|
analyticsHandler = _ref.analyticsHandler,
|
|
19
17
|
analytics = _ref.analytics,
|
|
20
18
|
_ref$canOpen = _ref.canOpen,
|
|
@@ -124,11 +122,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
124
122
|
}, [closeOnChildClick, hideCard]);
|
|
125
123
|
var content = useCallback(function (_ref2) {
|
|
126
124
|
var update = _ref2.update;
|
|
127
|
-
return jsx(
|
|
128
|
-
url: url,
|
|
129
|
-
appearance: CardDisplay.HoverCardPreview,
|
|
130
|
-
id: id
|
|
131
|
-
}, jsx(HoverCardContent, {
|
|
125
|
+
return jsx(HoverCardContent, {
|
|
132
126
|
onMouseEnter: initShowCard,
|
|
133
127
|
onMouseLeave: initHideCard,
|
|
134
128
|
analytics: analytics,
|
|
@@ -138,10 +132,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
138
132
|
onResolve: update,
|
|
139
133
|
renderers: renderers,
|
|
140
134
|
showServerActions: showServerActions,
|
|
141
|
-
url: url
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}, [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
|
|
135
|
+
url: url
|
|
136
|
+
});
|
|
137
|
+
}, [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url]);
|
|
145
138
|
var trigger = useCallback(function (triggerProps) {
|
|
146
139
|
return jsx("span", {
|
|
147
140
|
ref: parentSpan
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InvokeRequest } from '@atlaskit/linking-types/smart-link-actions';
|
|
2
|
+
import { PreviewActionData } from '../../flexible-ui-context/types';
|
|
2
3
|
/**
|
|
3
4
|
* Additional details for invoke function that may be required for component
|
|
4
5
|
*/
|
|
@@ -11,6 +12,10 @@ export declare type CardDetails = {
|
|
|
11
12
|
* The URL of the Smart Link
|
|
12
13
|
*/
|
|
13
14
|
url?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Preview Modal information. If present, will be used to render an embed modal on an error link click
|
|
17
|
+
*/
|
|
18
|
+
previewData?: PreviewActionData | null;
|
|
14
19
|
};
|
|
15
20
|
/**
|
|
16
21
|
* Invoke request with additional details for the component
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CardWithUrlContentProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function CardWithUrlContent({ id, url, isSelected, isFrameVisible, frameStyle, platform, onClick, appearance, dispatchAnalytics, onResolve, onError, testId, showActions, showServerActions: showServerActionsProp, inheritDimensions, embedIframeRef, embedIframeUrlType, inlinePreloaderStyle, ui, children, showHoverPreview, showAuthTooltip: showAuthTooltipProp, analyticsEvents, }: CardWithUrlContentProps): JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PreviewFunctionProps } from '../FlexibleCard/components/actions/action/preview-action/types';
|
|
2
|
+
import { PreviewActionData } from '../../state/flexible-ui-context/types';
|
|
3
|
+
import { AnalyticsFacade } from '../../state/analytics';
|
|
4
|
+
declare type PreviewModalProps = {
|
|
5
|
+
analytics?: AnalyticsFacade;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
} & PreviewActionData;
|
|
8
|
+
export declare const openPreviewModal: ({ analytics, downloadUrl: download, isSupportTheming, linkIcon, onClose, providerName, src, title, url, }: PreviewModalProps) => Promise<void>;
|
|
9
|
+
export declare function previewFunction({ popupMountPointId, onClose: onEmbedClose, ...rest }: PreviewFunctionProps): Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PreviewActionProps
|
|
2
|
+
import { PreviewActionProps } from './types';
|
|
3
3
|
declare const PreviewAction: React.FC<PreviewActionProps>;
|
|
4
|
-
export declare function previewFunction({ popupMountPointId, ...rest }: PreviewFunctionProps): Promise<void>;
|
|
5
4
|
export default PreviewAction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const dropdownItemGroupStyles: import("@emotion/react").SerializedStyles;
|
|
2
2
|
export declare const contentStyles: import("@emotion/react").SerializedStyles;
|
|
3
|
+
export declare const linkStyles: import("@emotion/react").SerializedStyles;
|
|
3
4
|
export declare const textStyles: (maxLines: number) => import("@emotion/react").SerializedStyles;
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import { MessageProps } from '../../../types';
|
|
2
|
+
import { PreviewActionData } from '../../../../../../state/flexible-ui-context/types';
|
|
2
3
|
export declare type LozengeActionErrorProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Error message to be displayed inside the dropdown
|
|
6
|
+
*/
|
|
3
7
|
errorMessage: string | MessageProps;
|
|
8
|
+
/**
|
|
9
|
+
* Data test id used for testing purposes
|
|
10
|
+
*/
|
|
4
11
|
testId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum number of lines displayed inside of the dropdown
|
|
14
|
+
*/
|
|
5
15
|
maxLineNumber?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The url of the link. Used in reload functionality
|
|
18
|
+
*/
|
|
19
|
+
url?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Preview Modal information. If present, will be used to render an embed modal on an error link click
|
|
22
|
+
*/
|
|
23
|
+
previewData?: PreviewActionData | null;
|
|
6
24
|
};
|
|
7
25
|
export declare const LozengeActionErrorMessages: {
|
|
8
26
|
noData: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "25.9.
|
|
3
|
+
"version": "25.9.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@atlaskit/icon-object": "^6.2.0",
|
|
34
34
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
35
35
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
36
|
-
"@atlaskit/link-analytics": "^7.0.5",
|
|
37
36
|
"@atlaskit/link-client-extension": "^0.5.0",
|
|
38
37
|
"@atlaskit/linking-common": "^2.6.0",
|
|
39
38
|
"@atlaskit/linking-types": "^1.3.0",
|