@atlaskit/smart-card 25.9.2 → 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 +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/index.js +43 -26
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/index.js +19 -5
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/index.js +44 -27
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js +2 -2
- package/dist/types/view/Card/types.d.ts +0 -2
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/types.d.ts +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/version.json
CHANGED
|
@@ -43,26 +43,39 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
43
43
|
testId = _ref$testId === void 0 ? 'smart-element-lozenge-action' : _ref$testId,
|
|
44
44
|
text = _ref.text,
|
|
45
45
|
zIndex = _ref.zIndex;
|
|
46
|
-
var _useState = (0, _react2.useState)(
|
|
46
|
+
var _useState = (0, _react2.useState)({
|
|
47
|
+
appearance: appearance,
|
|
48
|
+
text: text
|
|
49
|
+
}),
|
|
47
50
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
selected = _useState2[0],
|
|
52
|
+
setSelected = _useState2[1];
|
|
50
53
|
var _useState3 = (0, _react2.useState)(false),
|
|
51
54
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
isLoaded = _useState4[0],
|
|
56
|
+
setIsLoaded = _useState4[1];
|
|
54
57
|
var _useState5 = (0, _react2.useState)(false),
|
|
55
58
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var _useState7 = (0, _react2.useState)(),
|
|
59
|
+
isLoading = _useState6[0],
|
|
60
|
+
setIsLoading = _useState6[1];
|
|
61
|
+
var _useState7 = (0, _react2.useState)(false),
|
|
59
62
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
isOpen = _useState8[0],
|
|
64
|
+
setIsOpen = _useState8[1];
|
|
62
65
|
var _useState9 = (0, _react2.useState)(),
|
|
63
66
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
items = _useState10[0],
|
|
68
|
+
setItems = _useState10[1];
|
|
69
|
+
var _useState11 = (0, _react2.useState)(),
|
|
70
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
71
|
+
errorMessage = _useState12[0],
|
|
72
|
+
setErrorMessage = _useState12[1];
|
|
73
|
+
(0, _react2.useEffect)(function () {
|
|
74
|
+
setSelected({
|
|
75
|
+
text: text,
|
|
76
|
+
appearance: appearance
|
|
77
|
+
});
|
|
78
|
+
}, [text, appearance]);
|
|
66
79
|
var invoke = (0, _useInvoke.default)();
|
|
67
80
|
var reload = (0, _useResolve.default)();
|
|
68
81
|
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
@@ -122,13 +135,13 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
122
135
|
}(), [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
123
136
|
var trigger = (0, _react2.useCallback)(function (props) {
|
|
124
137
|
return (0, _react.jsx)(_lozengeActionTrigger.default, (0, _extends2.default)({}, props, {
|
|
125
|
-
appearance: appearance,
|
|
138
|
+
appearance: selected.appearance,
|
|
126
139
|
testId: testId,
|
|
127
|
-
text: text
|
|
140
|
+
text: selected.text
|
|
128
141
|
}));
|
|
129
|
-
}, [
|
|
142
|
+
}, [testId, selected]);
|
|
130
143
|
var handleItemClick = (0, _react2.useCallback)( /*#__PURE__*/function () {
|
|
131
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id) {
|
|
144
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, text, appearance) {
|
|
132
145
|
var updateAction, request;
|
|
133
146
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
134
147
|
while (1) {
|
|
@@ -137,7 +150,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
137
150
|
_context2.prev = 0;
|
|
138
151
|
updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
139
152
|
if (!(updateAction && id)) {
|
|
140
|
-
_context2.next =
|
|
153
|
+
_context2.next = 15;
|
|
141
154
|
break;
|
|
142
155
|
}
|
|
143
156
|
setIsLoading(true);
|
|
@@ -145,21 +158,25 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
145
158
|
_context2.next = 7;
|
|
146
159
|
return invoke(request);
|
|
147
160
|
case 7:
|
|
161
|
+
setSelected({
|
|
162
|
+
appearance: appearance,
|
|
163
|
+
text: text
|
|
164
|
+
});
|
|
148
165
|
setIsLoading(false);
|
|
149
166
|
setIsLoaded(false);
|
|
150
167
|
setIsOpen(false);
|
|
151
168
|
setItems([]);
|
|
152
169
|
if (!url) {
|
|
153
|
-
_context2.next =
|
|
170
|
+
_context2.next = 15;
|
|
154
171
|
break;
|
|
155
172
|
}
|
|
156
|
-
_context2.next =
|
|
173
|
+
_context2.next = 15;
|
|
157
174
|
return reload(url, true, undefined, linkId);
|
|
158
|
-
case
|
|
159
|
-
_context2.next =
|
|
175
|
+
case 15:
|
|
176
|
+
_context2.next = 21;
|
|
160
177
|
break;
|
|
161
|
-
case
|
|
162
|
-
_context2.prev =
|
|
178
|
+
case 17:
|
|
179
|
+
_context2.prev = 17;
|
|
163
180
|
_context2.t0 = _context2["catch"](0);
|
|
164
181
|
setIsLoading(false);
|
|
165
182
|
if (isInvokeCustomError(_context2.t0)) {
|
|
@@ -167,14 +184,14 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
167
184
|
} else {
|
|
168
185
|
setErrorMessage(_types.LozengeActionErrorMessages.updateFailed);
|
|
169
186
|
}
|
|
170
|
-
case
|
|
187
|
+
case 21:
|
|
171
188
|
case "end":
|
|
172
189
|
return _context2.stop();
|
|
173
190
|
}
|
|
174
191
|
}
|
|
175
|
-
}, _callee2, null, [[0,
|
|
192
|
+
}, _callee2, null, [[0, 17]]);
|
|
176
193
|
}));
|
|
177
|
-
return function (_x2) {
|
|
194
|
+
return function (_x2, _x3, _x4) {
|
|
178
195
|
return _ref4.apply(this, arguments);
|
|
179
196
|
};
|
|
180
197
|
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js
CHANGED
|
@@ -22,9 +22,9 @@ var LozengeActionItem = function LozengeActionItem(_ref) {
|
|
|
22
22
|
// We want to show loading screen.
|
|
23
23
|
e.stopPropagation();
|
|
24
24
|
if (onClick) {
|
|
25
|
-
onClick(id);
|
|
25
|
+
onClick(id, text, appearance);
|
|
26
26
|
}
|
|
27
|
-
}, [id, onClick]);
|
|
27
|
+
}, [appearance, id, onClick, text]);
|
|
28
28
|
var handleMouseEnter = (0, _react.useCallback)(function (e) {
|
|
29
29
|
var _e$currentTarget, _e$currentTarget$firs;
|
|
30
30
|
(_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();
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import DropdownMenu, { DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
6
6
|
import LozengeActionItem from './lozenge-action-item';
|
|
7
7
|
import LozengeActionTrigger from './lozenge-action-trigger';
|
|
@@ -25,11 +25,21 @@ const LozengeAction = ({
|
|
|
25
25
|
zIndex
|
|
26
26
|
}) => {
|
|
27
27
|
var _action$update;
|
|
28
|
+
const [selected, setSelected] = useState({
|
|
29
|
+
appearance,
|
|
30
|
+
text
|
|
31
|
+
});
|
|
28
32
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
29
33
|
const [isLoading, setIsLoading] = useState(false);
|
|
30
34
|
const [isOpen, setIsOpen] = useState(false);
|
|
31
35
|
const [items, setItems] = useState();
|
|
32
36
|
const [errorMessage, setErrorMessage] = useState();
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setSelected({
|
|
39
|
+
text,
|
|
40
|
+
appearance
|
|
41
|
+
});
|
|
42
|
+
}, [text, appearance]);
|
|
33
43
|
const invoke = useInvoke();
|
|
34
44
|
const reload = useResolve();
|
|
35
45
|
const {
|
|
@@ -62,17 +72,21 @@ const LozengeAction = ({
|
|
|
62
72
|
}
|
|
63
73
|
}, [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
64
74
|
const trigger = useCallback(props => jsx(LozengeActionTrigger, _extends({}, props, {
|
|
65
|
-
appearance: appearance,
|
|
75
|
+
appearance: selected.appearance,
|
|
66
76
|
testId: testId,
|
|
67
|
-
text: text
|
|
68
|
-
})), [
|
|
69
|
-
const handleItemClick = useCallback(async id => {
|
|
77
|
+
text: selected.text
|
|
78
|
+
})), [testId, selected]);
|
|
79
|
+
const handleItemClick = useCallback(async (id, text, appearance) => {
|
|
70
80
|
try {
|
|
71
81
|
const updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
72
82
|
if (updateAction && id) {
|
|
73
83
|
setIsLoading(true);
|
|
74
84
|
const request = createStatusUpdateRequest(updateAction, id);
|
|
75
85
|
await invoke(request);
|
|
86
|
+
setSelected({
|
|
87
|
+
appearance,
|
|
88
|
+
text
|
|
89
|
+
});
|
|
76
90
|
setIsLoading(false);
|
|
77
91
|
setIsLoaded(false);
|
|
78
92
|
setIsOpen(false);
|
package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-item/index.js
CHANGED
|
@@ -13,9 +13,9 @@ const LozengeActionItem = ({
|
|
|
13
13
|
// We want to show loading screen.
|
|
14
14
|
e.stopPropagation();
|
|
15
15
|
if (onClick) {
|
|
16
|
-
onClick(id);
|
|
16
|
+
onClick(id, text, appearance);
|
|
17
17
|
}
|
|
18
|
-
}, [id, onClick]);
|
|
18
|
+
}, [appearance, id, onClick, text]);
|
|
19
19
|
const handleMouseEnter = useCallback(e => {
|
|
20
20
|
var _e$currentTarget, _e$currentTarget$firs;
|
|
21
21
|
(_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();
|
package/dist/esm/version.json
CHANGED
|
@@ -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';
|
|
@@ -35,26 +35,39 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
35
35
|
testId = _ref$testId === void 0 ? 'smart-element-lozenge-action' : _ref$testId,
|
|
36
36
|
text = _ref.text,
|
|
37
37
|
zIndex = _ref.zIndex;
|
|
38
|
-
var _useState = useState(
|
|
38
|
+
var _useState = useState({
|
|
39
|
+
appearance: appearance,
|
|
40
|
+
text: text
|
|
41
|
+
}),
|
|
39
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
selected = _useState2[0],
|
|
44
|
+
setSelected = _useState2[1];
|
|
42
45
|
var _useState3 = useState(false),
|
|
43
46
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
isLoaded = _useState4[0],
|
|
48
|
+
setIsLoaded = _useState4[1];
|
|
46
49
|
var _useState5 = useState(false),
|
|
47
50
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var _useState7 = useState(),
|
|
51
|
+
isLoading = _useState6[0],
|
|
52
|
+
setIsLoading = _useState6[1];
|
|
53
|
+
var _useState7 = useState(false),
|
|
51
54
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
isOpen = _useState8[0],
|
|
56
|
+
setIsOpen = _useState8[1];
|
|
54
57
|
var _useState9 = useState(),
|
|
55
58
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
56
|
-
|
|
57
|
-
|
|
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]);
|
|
58
71
|
var invoke = useInvoke();
|
|
59
72
|
var reload = useResolve();
|
|
60
73
|
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
@@ -114,13 +127,13 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
114
127
|
}(), [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
115
128
|
var trigger = useCallback(function (props) {
|
|
116
129
|
return jsx(LozengeActionTrigger, _extends({}, props, {
|
|
117
|
-
appearance: appearance,
|
|
130
|
+
appearance: selected.appearance,
|
|
118
131
|
testId: testId,
|
|
119
|
-
text: text
|
|
132
|
+
text: selected.text
|
|
120
133
|
}));
|
|
121
|
-
}, [
|
|
134
|
+
}, [testId, selected]);
|
|
122
135
|
var handleItemClick = useCallback( /*#__PURE__*/function () {
|
|
123
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id) {
|
|
136
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, text, appearance) {
|
|
124
137
|
var updateAction, request;
|
|
125
138
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
126
139
|
while (1) {
|
|
@@ -129,7 +142,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
129
142
|
_context2.prev = 0;
|
|
130
143
|
updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
131
144
|
if (!(updateAction && id)) {
|
|
132
|
-
_context2.next =
|
|
145
|
+
_context2.next = 15;
|
|
133
146
|
break;
|
|
134
147
|
}
|
|
135
148
|
setIsLoading(true);
|
|
@@ -137,21 +150,25 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
137
150
|
_context2.next = 7;
|
|
138
151
|
return invoke(request);
|
|
139
152
|
case 7:
|
|
153
|
+
setSelected({
|
|
154
|
+
appearance: appearance,
|
|
155
|
+
text: text
|
|
156
|
+
});
|
|
140
157
|
setIsLoading(false);
|
|
141
158
|
setIsLoaded(false);
|
|
142
159
|
setIsOpen(false);
|
|
143
160
|
setItems([]);
|
|
144
161
|
if (!url) {
|
|
145
|
-
_context2.next =
|
|
162
|
+
_context2.next = 15;
|
|
146
163
|
break;
|
|
147
164
|
}
|
|
148
|
-
_context2.next =
|
|
165
|
+
_context2.next = 15;
|
|
149
166
|
return reload(url, true, undefined, linkId);
|
|
150
|
-
case
|
|
151
|
-
_context2.next =
|
|
167
|
+
case 15:
|
|
168
|
+
_context2.next = 21;
|
|
152
169
|
break;
|
|
153
|
-
case
|
|
154
|
-
_context2.prev =
|
|
170
|
+
case 17:
|
|
171
|
+
_context2.prev = 17;
|
|
155
172
|
_context2.t0 = _context2["catch"](0);
|
|
156
173
|
setIsLoading(false);
|
|
157
174
|
if (isInvokeCustomError(_context2.t0)) {
|
|
@@ -159,14 +176,14 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
159
176
|
} else {
|
|
160
177
|
setErrorMessage(LozengeActionErrorMessages.updateFailed);
|
|
161
178
|
}
|
|
162
|
-
case
|
|
179
|
+
case 21:
|
|
163
180
|
case "end":
|
|
164
181
|
return _context2.stop();
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
|
-
}, _callee2, null, [[0,
|
|
184
|
+
}, _callee2, null, [[0, 17]]);
|
|
168
185
|
}));
|
|
169
|
-
return function (_x2) {
|
|
186
|
+
return function (_x2, _x3, _x4) {
|
|
170
187
|
return _ref4.apply(this, arguments);
|
|
171
188
|
};
|
|
172
189
|
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
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();
|
|
@@ -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;
|
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
|
};
|