@atlaskit/smart-card 25.9.1 → 25.9.3
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 +12 -0
- package/dist/cjs/extractors/flexible/extract-state.js +4 -1
- package/dist/cjs/version.json +1 -1
- 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 +48 -25
- 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/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/es2019/extractors/flexible/extract-state.js +4 -1
- package/dist/es2019/version.json +1 -1
- 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 +30 -12
- 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/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/esm/extractors/flexible/extract-state.js +4 -1
- package/dist/esm/version.json +1 -1
- 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 +49 -26
- 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/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/types/state/hooks/use-invoke/types.d.ts +5 -0
- package/dist/types/view/Card/types.d.ts +0 -2
- 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/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/types.d.ts +3 -2
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
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; }
|
|
6
6
|
/** @jsx jsx */
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
import DropdownMenu, { DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
10
10
|
import LozengeActionItem from './lozenge-action-item';
|
|
11
11
|
import LozengeActionTrigger from './lozenge-action-trigger';
|
|
@@ -28,36 +28,54 @@ 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,
|
|
34
35
|
testId = _ref$testId === void 0 ? 'smart-element-lozenge-action' : _ref$testId,
|
|
35
36
|
text = _ref.text,
|
|
36
37
|
zIndex = _ref.zIndex;
|
|
37
|
-
var _useState = useState(
|
|
38
|
+
var _useState = useState({
|
|
39
|
+
appearance: appearance,
|
|
40
|
+
text: text
|
|
41
|
+
}),
|
|
38
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
selected = _useState2[0],
|
|
44
|
+
setSelected = _useState2[1];
|
|
41
45
|
var _useState3 = useState(false),
|
|
42
46
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
isLoaded = _useState4[0],
|
|
48
|
+
setIsLoaded = _useState4[1];
|
|
45
49
|
var _useState5 = useState(false),
|
|
46
50
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _useState7 = useState(),
|
|
51
|
+
isLoading = _useState6[0],
|
|
52
|
+
setIsLoading = _useState6[1];
|
|
53
|
+
var _useState7 = useState(false),
|
|
50
54
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
isOpen = _useState8[0],
|
|
56
|
+
setIsOpen = _useState8[1];
|
|
53
57
|
var _useState9 = useState(),
|
|
54
58
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
items = _useState10[0],
|
|
60
|
+
setItems = _useState10[1];
|
|
61
|
+
var _useState11 = useState(),
|
|
62
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
63
|
+
errorMessage = _useState12[0],
|
|
64
|
+
setErrorMessage = _useState12[1];
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
setSelected({
|
|
67
|
+
text: text,
|
|
68
|
+
appearance: appearance
|
|
69
|
+
});
|
|
70
|
+
}, [text, appearance]);
|
|
57
71
|
var invoke = useInvoke();
|
|
58
72
|
var reload = useResolve();
|
|
73
|
+
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
74
|
+
url = _ref2.url,
|
|
75
|
+
linkId = _ref2.id,
|
|
76
|
+
previewData = _ref2.previewData;
|
|
59
77
|
var handleOpenChange = useCallback( /*#__PURE__*/function () {
|
|
60
|
-
var
|
|
78
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
61
79
|
var responseItems, validItems;
|
|
62
80
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
81
|
while (1) {
|
|
@@ -104,19 +122,19 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
104
122
|
}, _callee, null, [[2, 13, 17, 20]]);
|
|
105
123
|
}));
|
|
106
124
|
return function (_x) {
|
|
107
|
-
return
|
|
125
|
+
return _ref3.apply(this, arguments);
|
|
108
126
|
};
|
|
109
127
|
}(), [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
110
128
|
var trigger = useCallback(function (props) {
|
|
111
129
|
return jsx(LozengeActionTrigger, _extends({}, props, {
|
|
112
|
-
appearance: appearance,
|
|
130
|
+
appearance: selected.appearance,
|
|
113
131
|
testId: testId,
|
|
114
|
-
text: text
|
|
132
|
+
text: selected.text
|
|
115
133
|
}));
|
|
116
|
-
}, [
|
|
134
|
+
}, [testId, selected]);
|
|
117
135
|
var handleItemClick = useCallback( /*#__PURE__*/function () {
|
|
118
|
-
var
|
|
119
|
-
var updateAction, request
|
|
136
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, text, appearance) {
|
|
137
|
+
var updateAction, request;
|
|
120
138
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
121
139
|
while (1) {
|
|
122
140
|
switch (_context2.prev = _context2.next) {
|
|
@@ -132,11 +150,14 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
132
150
|
_context2.next = 7;
|
|
133
151
|
return invoke(request);
|
|
134
152
|
case 7:
|
|
153
|
+
setSelected({
|
|
154
|
+
appearance: appearance,
|
|
155
|
+
text: text
|
|
156
|
+
});
|
|
135
157
|
setIsLoading(false);
|
|
136
158
|
setIsLoaded(false);
|
|
137
159
|
setIsOpen(false);
|
|
138
160
|
setItems([]);
|
|
139
|
-
_ref4 = updateAction.details || {}, url = _ref4.url, linkId = _ref4.id;
|
|
140
161
|
if (!url) {
|
|
141
162
|
_context2.next = 15;
|
|
142
163
|
break;
|
|
@@ -162,15 +183,17 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
162
183
|
}
|
|
163
184
|
}, _callee2, null, [[0, 17]]);
|
|
164
185
|
}));
|
|
165
|
-
return function (_x2) {
|
|
166
|
-
return
|
|
186
|
+
return function (_x2, _x3, _x4) {
|
|
187
|
+
return _ref4.apply(this, arguments);
|
|
167
188
|
};
|
|
168
|
-
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
|
|
189
|
+
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
|
169
190
|
var dropdownItemGroup = useMemo(function () {
|
|
170
191
|
if (errorMessage) {
|
|
171
192
|
return jsx(LozengeActionError, {
|
|
172
193
|
errorMessage: errorMessage,
|
|
173
|
-
testId: testId
|
|
194
|
+
testId: testId,
|
|
195
|
+
url: url,
|
|
196
|
+
previewData: previewData
|
|
174
197
|
});
|
|
175
198
|
}
|
|
176
199
|
if (items && items.length > 0) {
|
|
@@ -185,7 +208,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
185
208
|
}));
|
|
186
209
|
})));
|
|
187
210
|
}
|
|
188
|
-
}, [errorMessage, handleItemClick, items, testId]);
|
|
211
|
+
}, [errorMessage, handleItemClick, items, previewData, testId, url]);
|
|
189
212
|
return jsx(DropdownMenu, {
|
|
190
213
|
isLoading: isLoading,
|
|
191
214
|
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
|
};
|
package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js
CHANGED
|
@@ -12,9 +12,9 @@ var LozengeActionItem = function LozengeActionItem(_ref) {
|
|
|
12
12
|
// We want to show loading screen.
|
|
13
13
|
e.stopPropagation();
|
|
14
14
|
if (onClick) {
|
|
15
|
-
onClick(id);
|
|
15
|
+
onClick(id, text, appearance);
|
|
16
16
|
}
|
|
17
|
-
}, [id, onClick]);
|
|
17
|
+
}, [appearance, id, onClick, text]);
|
|
18
18
|
var handleMouseEnter = useCallback(function (e) {
|
|
19
19
|
var _e$currentTarget, _e$currentTarget$firs;
|
|
20
20
|
(_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : (_e$currentTarget$firs = _e$currentTarget.firstElementChild) === null || _e$currentTarget$firs === void 0 ? void 0 : _e$currentTarget$firs.focus();
|
|
@@ -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
|
|
@@ -37,8 +37,6 @@ export interface CardProps extends WithAnalyticsEventsProps {
|
|
|
37
37
|
*/
|
|
38
38
|
showActions?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
* @todo This is an experiment prop and the development is in-progress.
|
|
41
|
-
* @see ATLAS-13099
|
|
42
40
|
* Show server actions that change the link resource, e.g. update status.
|
|
43
41
|
*/
|
|
44
42
|
showServerActions?: boolean;
|
|
@@ -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/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ThemeAppearance } from '@atlaskit/lozenge';
|
|
2
|
+
import type { LozengeItem } from '../types';
|
|
2
3
|
export declare type LozengeActionItemProps = LozengeItem & {
|
|
3
|
-
onClick?: (id: string) => void;
|
|
4
|
+
onClick?: (id: string, text: string, appearance?: ThemeAppearance) => void;
|
|
4
5
|
testId?: string;
|
|
5
6
|
};
|