@atlaskit/link-picker 5.2.1 → 5.3.1
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 +19 -0
- package/dist/cjs/controllers/session-provider/index.js +1 -11
- package/dist/cjs/services/use-plugins/index.js +17 -17
- package/dist/cjs/services/use-plugins/utils.js +7 -6
- package/dist/cjs/ui/link-picker/index.js +54 -42
- package/dist/cjs/ui/main.js +1 -1
- package/dist/cjs/ui/messages-provider/lazy-messages-provider/utils/fetch-messages-for-locale.js +22 -22
- package/dist/es2019/controllers/session-provider/index.js +1 -9
- package/dist/es2019/ui/link-picker/index.js +20 -7
- package/dist/es2019/ui/main.js +1 -1
- package/dist/esm/controllers/session-provider/index.js +1 -11
- package/dist/esm/services/use-plugins/index.js +17 -17
- package/dist/esm/services/use-plugins/utils.js +7 -6
- package/dist/esm/ui/link-picker/index.js +43 -31
- package/dist/esm/ui/main.js +1 -1
- package/dist/esm/ui/messages-provider/lazy-messages-provider/utils/fetch-messages-for-locale.js +22 -22
- package/package.json +12 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/link-picker
|
|
2
2
|
|
|
3
|
+
## 5.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 5.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`fbb51c73ed426`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fbb51c73ed426) -
|
|
14
|
+
Update i18n NPM package versions for linking-platform,smart-experiences (Group 15)
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`cf3ee6a99c051`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cf3ee6a99c051) -
|
|
19
|
+
[ux] NAVX-4104 fixing the error focus state for link picker
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 5.2.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -13,27 +13,17 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
13
13
|
|
|
14
14
|
var INIT_CONTEXT = exports.INIT_CONTEXT = 'SESSION_UNINITIALIZED';
|
|
15
15
|
var SessionContext = exports.SessionContext = /*#__PURE__*/(0, _react.createContext)(INIT_CONTEXT);
|
|
16
|
-
var useConstructor = function useConstructor(callback) {
|
|
17
|
-
var hasBeenFired = (0, _react.useRef)(false);
|
|
18
|
-
if (!hasBeenFired.current) {
|
|
19
|
-
callback();
|
|
20
|
-
hasBeenFired.current = true;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
16
|
var LinkPickerSessionProvider = exports.LinkPickerSessionProvider = function LinkPickerSessionProvider(_ref) {
|
|
25
17
|
var children = _ref.children;
|
|
26
18
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
27
19
|
var _useRef = (0, _react.useRef)((0, _uuid.v4)()),
|
|
28
20
|
sessionId = _useRef.current;
|
|
29
21
|
(0, _react.useEffect)(function () {
|
|
22
|
+
(0, _experiences.startUfoExperience)(_experiences.ufoExperience.mounted, sessionId);
|
|
30
23
|
return function () {
|
|
31
24
|
return (0, _experiences.abortUfoExperience)(_experiences.ufoExperience.mounted, sessionId);
|
|
32
25
|
};
|
|
33
26
|
}, [sessionId]);
|
|
34
|
-
useConstructor(function () {
|
|
35
|
-
return (0, _experiences.startUfoExperience)(_experiences.ufoExperience.mounted, sessionId);
|
|
36
|
-
});
|
|
37
27
|
return /*#__PURE__*/_react.default.createElement(SessionContext.Provider, {
|
|
38
28
|
value: sessionId
|
|
39
29
|
}, children);
|
|
@@ -58,20 +58,20 @@ function usePlugins(state, activeTab, plugins, recentSearchListSize, alwaysShowT
|
|
|
58
58
|
cancel = _resolvePluginUpdates.cancel;
|
|
59
59
|
var updateResults = /*#__PURE__*/function () {
|
|
60
60
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
61
|
-
var _isLoading, _yield$next, value, done;
|
|
62
|
-
return _regenerator.default.wrap(function
|
|
61
|
+
var _isLoading, _yield$next, value, done, _t;
|
|
62
|
+
return _regenerator.default.wrap(function (_context) {
|
|
63
63
|
while (1) switch (_context.prev = _context.next) {
|
|
64
64
|
case 0:
|
|
65
65
|
_context.prev = 0;
|
|
66
66
|
_isLoading = true;
|
|
67
|
-
case
|
|
67
|
+
case 1:
|
|
68
68
|
if (!_isLoading) {
|
|
69
|
-
_context.next =
|
|
69
|
+
_context.next = 3;
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
_context.next =
|
|
72
|
+
_context.next = 2;
|
|
73
73
|
return next();
|
|
74
|
-
case
|
|
74
|
+
case 2:
|
|
75
75
|
_yield$next = _context.sent;
|
|
76
76
|
value = _yield$next.value;
|
|
77
77
|
done = _yield$next.done;
|
|
@@ -83,28 +83,28 @@ function usePlugins(state, activeTab, plugins, recentSearchListSize, alwaysShowT
|
|
|
83
83
|
isLoading: !done
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
-
_context.next =
|
|
86
|
+
_context.next = 1;
|
|
87
87
|
break;
|
|
88
|
-
case
|
|
89
|
-
_context.next =
|
|
88
|
+
case 3:
|
|
89
|
+
_context.next = 5;
|
|
90
90
|
break;
|
|
91
|
-
case
|
|
92
|
-
_context.prev =
|
|
93
|
-
|
|
94
|
-
if (!(
|
|
91
|
+
case 4:
|
|
92
|
+
_context.prev = 4;
|
|
93
|
+
_t = _context["catch"](0);
|
|
94
|
+
if (!(_t instanceof _utils.CancellationError)) {
|
|
95
95
|
dispatch({
|
|
96
96
|
type: 'ERROR',
|
|
97
|
-
payload:
|
|
97
|
+
payload: _t
|
|
98
98
|
});
|
|
99
99
|
createAnalyticsEvent((0, _analytics2.default)('operational.resultsResolve.failed', {
|
|
100
|
-
error: (0, _convertToError.convertToError)(
|
|
100
|
+
error: (0, _convertToError.convertToError)(_t).toString()
|
|
101
101
|
})).fire(_constants.ANALYTICS_CHANNEL);
|
|
102
102
|
}
|
|
103
|
-
case
|
|
103
|
+
case 5:
|
|
104
104
|
case "end":
|
|
105
105
|
return _context.stop();
|
|
106
106
|
}
|
|
107
|
-
}, _callee, null, [[0,
|
|
107
|
+
}, _callee, null, [[0, 4]]);
|
|
108
108
|
}));
|
|
109
109
|
return function updateResults() {
|
|
110
110
|
return _ref.apply(this, arguments);
|
|
@@ -52,18 +52,19 @@ var resolvePluginUpdates = exports.resolvePluginUpdates = function resolvePlugin
|
|
|
52
52
|
cancel: cancel,
|
|
53
53
|
next: function () {
|
|
54
54
|
var _next = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
55
|
-
|
|
55
|
+
var _t;
|
|
56
|
+
return _regenerator.default.wrap(function (_context) {
|
|
56
57
|
while (1) switch (_context.prev = _context.next) {
|
|
57
58
|
case 0:
|
|
58
|
-
_context.next =
|
|
59
|
+
_context.next = 1;
|
|
59
60
|
return promise;
|
|
60
|
-
case
|
|
61
|
-
|
|
61
|
+
case 1:
|
|
62
|
+
_t = _context.sent;
|
|
62
63
|
return _context.abrupt("return", {
|
|
63
|
-
value:
|
|
64
|
+
value: _t,
|
|
64
65
|
done: true
|
|
65
66
|
});
|
|
66
|
-
case
|
|
67
|
+
case 2:
|
|
67
68
|
case "end":
|
|
68
69
|
return _context.stop();
|
|
69
70
|
}
|
|
@@ -8,20 +8,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
});
|
|
9
9
|
exports.testIds = exports.LinkPicker = void 0;
|
|
10
10
|
require("./index.compiled.css");
|
|
11
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
var React = _react;
|
|
13
11
|
var _runtime = require("@compiled/react/runtime");
|
|
14
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
18
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
18
|
var _reactIntl = require("react-intl");
|
|
19
|
+
var _useCallbackRef = require("use-callback-ref");
|
|
20
20
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
21
21
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
22
22
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
23
23
|
var _url2 = require("@atlaskit/linking-common/url");
|
|
24
24
|
var _userAgent = require("@atlaskit/linking-common/user-agent");
|
|
25
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
26
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
26
27
|
var _linkUrl = _interopRequireDefault(require("@atlaskit/smart-card/link-url"));
|
|
27
28
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
@@ -40,7 +41,7 @@ var _searchResults = require("./search-results");
|
|
|
40
41
|
var _textInput = require("./text-input");
|
|
41
42
|
var _trackMount = require("./track-mount");
|
|
42
43
|
var _utils = require("./utils");
|
|
43
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
44
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
44
45
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
45
46
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
46
47
|
var styles = {
|
|
@@ -120,6 +121,8 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
120
121
|
alwaysShowTabs = _ref.alwaysShowTabs;
|
|
121
122
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
122
123
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
124
|
+
var linkInputRef = _react.default.useRef(null);
|
|
125
|
+
var mergedRefs = (0, _useCallbackRef.useMergeRefs)(inputRef ? [linkInputRef, inputRef] : [linkInputRef]);
|
|
123
126
|
var _useReducer = (0, _react.useReducer)(reducer, _objectSpread(_objectSpread({}, initState), {}, {
|
|
124
127
|
url: (0, _url2.normalizeUrl)(initUrl) || '',
|
|
125
128
|
displayText: initDisplayText || ''
|
|
@@ -247,71 +250,74 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
247
250
|
}, [dispatch]);
|
|
248
251
|
var handleSubmit = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
249
252
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(event) {
|
|
250
|
-
var normalized, urlResponse, responseObject;
|
|
251
|
-
return _regenerator.default.wrap(function
|
|
253
|
+
var normalized, urlResponse, responseObject, _linkInputRef$current, _t;
|
|
254
|
+
return _regenerator.default.wrap(function (_context) {
|
|
252
255
|
while (1) switch (_context.prev = _context.next) {
|
|
253
256
|
case 0:
|
|
254
257
|
event === null || event === void 0 || event.preventDefault();
|
|
255
258
|
if (!isSubmitting) {
|
|
256
|
-
_context.next =
|
|
259
|
+
_context.next = 1;
|
|
257
260
|
break;
|
|
258
261
|
}
|
|
259
262
|
return _context.abrupt("return");
|
|
260
|
-
case
|
|
263
|
+
case 1:
|
|
261
264
|
if (!(isSelectedItem && selectedItem)) {
|
|
262
|
-
_context.next =
|
|
265
|
+
_context.next = 2;
|
|
263
266
|
break;
|
|
264
267
|
}
|
|
265
268
|
return _context.abrupt("return", handleInsert(selectedItem.url, selectedItem.name, 'typeAhead'));
|
|
266
|
-
case
|
|
269
|
+
case 2:
|
|
267
270
|
normalized = (0, _url2.normalizeUrl)(url);
|
|
268
271
|
if (!normalized) {
|
|
269
|
-
_context.next =
|
|
272
|
+
_context.next = 10;
|
|
270
273
|
break;
|
|
271
274
|
}
|
|
272
275
|
if (!previewableLinksOnly) {
|
|
273
|
-
_context.next =
|
|
276
|
+
_context.next = 9;
|
|
274
277
|
break;
|
|
275
278
|
}
|
|
276
|
-
_context.prev =
|
|
277
|
-
_context.next =
|
|
279
|
+
_context.prev = 3;
|
|
280
|
+
_context.next = 4;
|
|
278
281
|
return client.fetchData(normalized);
|
|
279
|
-
case
|
|
282
|
+
case 4:
|
|
280
283
|
urlResponse = _context.sent;
|
|
281
284
|
responseObject = urlResponse === null || urlResponse === void 0 ? void 0 : urlResponse.data;
|
|
282
285
|
if (!(responseObject && 'preview' in responseObject)) {
|
|
283
|
-
_context.next =
|
|
286
|
+
_context.next = 5;
|
|
284
287
|
break;
|
|
285
288
|
}
|
|
286
289
|
return _context.abrupt("return", handleInsert(normalized, null, 'manual'));
|
|
287
|
-
case
|
|
290
|
+
case 5:
|
|
288
291
|
return _context.abrupt("return", dispatch({
|
|
289
292
|
invalidUrl: true,
|
|
290
293
|
hasPreview: false
|
|
291
294
|
}));
|
|
292
|
-
case
|
|
293
|
-
_context.next =
|
|
295
|
+
case 6:
|
|
296
|
+
_context.next = 8;
|
|
294
297
|
break;
|
|
295
|
-
case
|
|
296
|
-
_context.prev =
|
|
297
|
-
|
|
298
|
+
case 7:
|
|
299
|
+
_context.prev = 7;
|
|
300
|
+
_t = _context["catch"](3);
|
|
298
301
|
return _context.abrupt("return", dispatch({
|
|
299
302
|
invalidUrl: true
|
|
300
303
|
}));
|
|
301
|
-
case
|
|
302
|
-
_context.next =
|
|
304
|
+
case 8:
|
|
305
|
+
_context.next = 10;
|
|
303
306
|
break;
|
|
304
|
-
case
|
|
307
|
+
case 9:
|
|
305
308
|
return _context.abrupt("return", handleInsert(normalized, null, 'manual'));
|
|
306
|
-
case
|
|
309
|
+
case 10:
|
|
310
|
+
if ((0, _platformFeatureFlags.fg)('navx-4104-link-picker-a11y-focus-states')) {
|
|
311
|
+
(_linkInputRef$current = linkInputRef.current) === null || _linkInputRef$current === void 0 || _linkInputRef$current.focus();
|
|
312
|
+
}
|
|
307
313
|
return _context.abrupt("return", dispatch({
|
|
308
314
|
invalidUrl: true
|
|
309
315
|
}));
|
|
310
|
-
case
|
|
316
|
+
case 11:
|
|
311
317
|
case "end":
|
|
312
318
|
return _context.stop();
|
|
313
319
|
}
|
|
314
|
-
}, _callee, null, [[
|
|
320
|
+
}, _callee, null, [[3, 7]]);
|
|
315
321
|
}));
|
|
316
322
|
return function (_x) {
|
|
317
323
|
return _ref2.apply(this, arguments);
|
|
@@ -412,35 +418,38 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
412
418
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
413
419
|
var screenReaderText = (0, _userAgent.browser)().safari && (0, _utils.getScreenReaderText)(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
414
420
|
var customSubmitButtonLabel = customMessages !== null && customMessages !== void 0 && customMessages.submitButtonLabel ? customMessages.submitButtonLabel : undefined;
|
|
415
|
-
var errorMessage = invalidUrl ? previewableLinksOnly && !hasPreview ? /*#__PURE__*/
|
|
421
|
+
var errorMessage = invalidUrl ? previewableLinksOnly && !hasPreview ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, (0, _extends2.default)({}, _messages.formMessages.noEmbedAvailable, {
|
|
416
422
|
values: {
|
|
417
423
|
a: function a(chunk) {
|
|
418
|
-
return /*#__PURE__*/
|
|
424
|
+
return /*#__PURE__*/_react.default.createElement(_linkUrl.default, {
|
|
419
425
|
target: "_blank",
|
|
420
426
|
href: "https://support.atlassian.com/platform-experiences/docs/smart-links-from-jira-and-other-products/"
|
|
421
427
|
}, chunk);
|
|
422
428
|
}
|
|
423
429
|
}
|
|
424
430
|
})) : intl.formatMessage(_messages.formMessages.linkInvalid) : null;
|
|
425
|
-
return /*#__PURE__*/
|
|
431
|
+
return /*#__PURE__*/_react.default.createElement("form", (0, _extends2.default)({
|
|
426
432
|
"data-testid": testIds.linkPicker,
|
|
427
433
|
// Use onSubmitCapture instead of onSubmit so that any possible parent form isn't submitted
|
|
428
|
-
onSubmitCapture: handleSubmit
|
|
434
|
+
onSubmitCapture: handleSubmit
|
|
435
|
+
}, (0, _platformFeatureFlags.fg)('navx-4104-link-picker-a11y-focus-states') ? {
|
|
436
|
+
noValidate: true
|
|
437
|
+
} : {}, {
|
|
429
438
|
className: (0, _runtime.ax)(["_19bv164s _u5f31pah _ca0q1k79 _n3td1t3k _vchhusvi _1e0ctcjq"])
|
|
430
|
-
}, /*#__PURE__*/
|
|
439
|
+
}), /*#__PURE__*/_react.default.createElement(_trackMount.TrackMount, null), submitOnInputChange && /*#__PURE__*/_react.default.createElement(_autoSubmitOnChange.default, {
|
|
431
440
|
url: url,
|
|
432
441
|
isSubmitting: isSubmitting,
|
|
433
442
|
isSelectedItem: isSelectedItem,
|
|
434
443
|
onSubmit: handleSubmit,
|
|
435
444
|
onClearInvalidUrl: handleClearInvalidUrl
|
|
436
|
-
}), isActivePlugin && /*#__PURE__*/
|
|
445
|
+
}), isActivePlugin && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, screenReaderText && /*#__PURE__*/_react.default.createElement(_announcer.Announcer, {
|
|
437
446
|
ariaLive: "assertive",
|
|
438
447
|
text: screenReaderText,
|
|
439
448
|
ariaRelevant: "additions",
|
|
440
449
|
delay: 250
|
|
441
|
-
}), /*#__PURE__*/
|
|
450
|
+
}), /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, {
|
|
442
451
|
id: screenReaderDescriptionId
|
|
443
|
-
}, customMessages !== null && customMessages !== void 0 && customMessages.linkAriaLabel ? /*#__PURE__*/
|
|
452
|
+
}, customMessages !== null && customMessages !== void 0 && customMessages.linkAriaLabel ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, customMessages.linkAriaLabel) : /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.linkAriaLabel))), /*#__PURE__*/_react.default.createElement(LinkInputField, (0, _extends2.default)({
|
|
444
453
|
name: "url",
|
|
445
454
|
autoComplete: "off",
|
|
446
455
|
testId: testIds.urlInputField,
|
|
@@ -449,16 +458,19 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
449
458
|
value: url,
|
|
450
459
|
autoFocus: true,
|
|
451
460
|
clearLabel: intl.formatMessage(_messages.formMessages.clearLink),
|
|
452
|
-
error: errorMessage || additionalError
|
|
461
|
+
error: errorMessage || additionalError
|
|
462
|
+
}, (0, _platformFeatureFlags.fg)('navx-4104-link-picker-a11y-focus-states') ? {
|
|
463
|
+
validationMessage: intl.formatMessage(_messages.formMessages.linkInvalid)
|
|
464
|
+
} : {}, {
|
|
453
465
|
spotlightTargetName: "link-picker-search-field-spotlight-target",
|
|
454
466
|
"aria-readonly": isSubmitting
|
|
455
467
|
}, a11yList, {
|
|
456
468
|
onClear: handleUrlClear,
|
|
457
469
|
onKeyDown: handleKeyDown,
|
|
458
470
|
onChange: handleChangeUrl,
|
|
459
|
-
inputRef: inputRef,
|
|
471
|
+
inputRef: (0, _platformFeatureFlags.fg)('navx-4104-link-picker-a11y-focus-states') ? mergedRefs : inputRef,
|
|
460
472
|
isRequired: true
|
|
461
|
-
})), !hideDisplayText && /*#__PURE__*/
|
|
473
|
+
})), !hideDisplayText && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(DisplayTextInputField, {
|
|
462
474
|
autoComplete: "off",
|
|
463
475
|
name: "displayText",
|
|
464
476
|
testId: testIds.textInputField,
|
|
@@ -470,9 +482,9 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
470
482
|
onClear: handleClear,
|
|
471
483
|
onChange: handleChangeText,
|
|
472
484
|
helperMessage: intl.formatMessage((_customMessages$linkH = customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) !== null && _customMessages$linkH !== void 0 ? _customMessages$linkH : _messages.linkTextMessages.linkHelperTextLabel)
|
|
473
|
-
})), moveSubmitButton && /*#__PURE__*/
|
|
485
|
+
})), moveSubmitButton && /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
474
486
|
xcss: styles.fullWidthSubmitButton
|
|
475
|
-
}, /*#__PURE__*/
|
|
487
|
+
}, /*#__PURE__*/_react.default.createElement(_linkPickerSubmitButton.LinkPickerSubmitButton, {
|
|
476
488
|
isEditing: isEditing,
|
|
477
489
|
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
478
490
|
isSubmitting: isSubmitting,
|
|
@@ -483,7 +495,7 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
483
495
|
submitMessageId: submitMessageId,
|
|
484
496
|
testId: testIds.insertButton,
|
|
485
497
|
url: url
|
|
486
|
-
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/
|
|
498
|
+
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/_react.default.createElement(_searchResults.SearchResults, {
|
|
487
499
|
activeTab: activeTab,
|
|
488
500
|
tabs: tabs,
|
|
489
501
|
activePlugin: activePlugin,
|
|
@@ -504,7 +516,7 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
504
516
|
adaptiveHeight: adaptiveHeight,
|
|
505
517
|
retry: retry,
|
|
506
518
|
shouldRenderNoResultsImage: shouldRenderNoResultsImage
|
|
507
|
-
}), /*#__PURE__*/
|
|
519
|
+
}), /*#__PURE__*/_react.default.createElement(_formFooter.FormFooter, {
|
|
508
520
|
error: error,
|
|
509
521
|
items: items
|
|
510
522
|
/** If the results section appears to be loading, impact whether the submit button is disabled */,
|
package/dist/cjs/ui/main.js
CHANGED
|
@@ -26,7 +26,7 @@ var testIds = exports.testIds = {
|
|
|
26
26
|
};
|
|
27
27
|
var PACKAGE_DATA = exports.PACKAGE_DATA = {
|
|
28
28
|
packageName: "@atlaskit/link-picker" || '',
|
|
29
|
-
packageVersion: "5.
|
|
29
|
+
packageVersion: "5.3.0" || '',
|
|
30
30
|
componentName: _constants.COMPONENT_NAME,
|
|
31
31
|
source: _constants.COMPONENT_NAME
|
|
32
32
|
};
|
package/dist/cjs/ui/messages-provider/lazy-messages-provider/utils/fetch-messages-for-locale.js
CHANGED
|
@@ -10,50 +10,50 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _i18n = require("../../../../i18n");
|
|
11
11
|
var fetchMessagesForLocale = exports.fetchMessagesForLocale = /*#__PURE__*/function () {
|
|
12
12
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(locale) {
|
|
13
|
-
var localeKey, messages, parentLocale, _messages;
|
|
14
|
-
return _regenerator.default.wrap(function
|
|
13
|
+
var localeKey, messages, parentLocale, _messages, _t, _t2;
|
|
14
|
+
return _regenerator.default.wrap(function (_context) {
|
|
15
15
|
while (1) switch (_context.prev = _context.next) {
|
|
16
16
|
case 0:
|
|
17
17
|
_context.prev = 0;
|
|
18
18
|
localeKey = locale.replace('-', '_');
|
|
19
19
|
if (!(localeKey in _i18n.locales)) {
|
|
20
|
-
_context.next =
|
|
20
|
+
_context.next = 2;
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
|
-
_context.next =
|
|
23
|
+
_context.next = 1;
|
|
24
24
|
return _i18n.locales[localeKey]();
|
|
25
|
-
case
|
|
25
|
+
case 1:
|
|
26
26
|
messages = _context.sent;
|
|
27
27
|
return _context.abrupt("return", messages.default);
|
|
28
|
-
case
|
|
29
|
-
_context.next =
|
|
28
|
+
case 2:
|
|
29
|
+
_context.next = 4;
|
|
30
30
|
break;
|
|
31
|
-
case
|
|
32
|
-
_context.prev =
|
|
33
|
-
|
|
34
|
-
case
|
|
35
|
-
_context.prev =
|
|
31
|
+
case 3:
|
|
32
|
+
_context.prev = 3;
|
|
33
|
+
_t = _context["catch"](0);
|
|
34
|
+
case 4:
|
|
35
|
+
_context.prev = 4;
|
|
36
36
|
parentLocale = locale.split(/[-_]/)[0];
|
|
37
37
|
if (!(parentLocale in _i18n.locales)) {
|
|
38
|
-
_context.next =
|
|
38
|
+
_context.next = 6;
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
_context.next =
|
|
41
|
+
_context.next = 5;
|
|
42
42
|
return _i18n.locales[parentLocale]();
|
|
43
|
-
case
|
|
43
|
+
case 5:
|
|
44
44
|
_messages = _context.sent;
|
|
45
45
|
return _context.abrupt("return", _messages.default);
|
|
46
|
-
case
|
|
47
|
-
_context.next =
|
|
46
|
+
case 6:
|
|
47
|
+
_context.next = 8;
|
|
48
48
|
break;
|
|
49
|
-
case
|
|
50
|
-
_context.prev =
|
|
51
|
-
|
|
52
|
-
case
|
|
49
|
+
case 7:
|
|
50
|
+
_context.prev = 7;
|
|
51
|
+
_t2 = _context["catch"](4);
|
|
52
|
+
case 8:
|
|
53
53
|
case "end":
|
|
54
54
|
return _context.stop();
|
|
55
55
|
}
|
|
56
|
-
}, _callee, null, [[0,
|
|
56
|
+
}, _callee, null, [[0, 3], [4, 7]]);
|
|
57
57
|
}));
|
|
58
58
|
return function fetchMessagesForLocale(_x) {
|
|
59
59
|
return _ref.apply(this, arguments);
|
|
@@ -5,14 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import { abortUfoExperience, startUfoExperience, ufoExperience } from '../../common/analytics/experiences';
|
|
6
6
|
export const INIT_CONTEXT = 'SESSION_UNINITIALIZED';
|
|
7
7
|
export const SessionContext = /*#__PURE__*/createContext(INIT_CONTEXT);
|
|
8
|
-
const useConstructor = callback => {
|
|
9
|
-
const hasBeenFired = useRef(false);
|
|
10
|
-
if (!hasBeenFired.current) {
|
|
11
|
-
callback();
|
|
12
|
-
hasBeenFired.current = true;
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
8
|
export const LinkPickerSessionProvider = ({
|
|
17
9
|
children
|
|
18
10
|
}) => {
|
|
@@ -21,9 +13,9 @@ export const LinkPickerSessionProvider = ({
|
|
|
21
13
|
current: sessionId
|
|
22
14
|
} = useRef(uuidv4());
|
|
23
15
|
useEffect(() => {
|
|
16
|
+
startUfoExperience(ufoExperience.mounted, sessionId);
|
|
24
17
|
return () => abortUfoExperience(ufoExperience.mounted, sessionId);
|
|
25
18
|
}, [sessionId]);
|
|
26
|
-
useConstructor(() => startUfoExperience(ufoExperience.mounted, sessionId));
|
|
27
19
|
return /*#__PURE__*/React.createElement(SessionContext.Provider, {
|
|
28
20
|
value: sessionId
|
|
29
21
|
}, children);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import "./index.compiled.css";
|
|
4
|
-
import * as React from 'react';
|
|
5
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
-
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
5
|
+
import React, { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
7
6
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
7
|
+
import { useMergeRefs } from 'use-callback-ref';
|
|
8
8
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
9
9
|
import uuid from 'uuid';
|
|
10
10
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
11
11
|
import { CardClient } from '@atlaskit/link-provider';
|
|
12
12
|
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
13
13
|
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
14
|
+
import { fg } from "@atlaskit/platform-feature-flags";
|
|
14
15
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
15
16
|
import LinkUrl from '@atlaskit/smart-card/link-url';
|
|
16
17
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -110,6 +111,8 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
110
111
|
const {
|
|
111
112
|
createAnalyticsEvent
|
|
112
113
|
} = useAnalyticsEvents();
|
|
114
|
+
const linkInputRef = React.useRef(null);
|
|
115
|
+
const mergedRefs = useMergeRefs(inputRef ? [linkInputRef, inputRef] : [linkInputRef]);
|
|
113
116
|
const [state, dispatch] = useReducer(reducer, {
|
|
114
117
|
...initState,
|
|
115
118
|
url: normalizeUrl(initUrl) || '',
|
|
@@ -272,6 +275,10 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
272
275
|
return handleInsert(normalized, null, 'manual');
|
|
273
276
|
}
|
|
274
277
|
}
|
|
278
|
+
if (fg('navx-4104-link-picker-a11y-focus-states')) {
|
|
279
|
+
var _linkInputRef$current;
|
|
280
|
+
(_linkInputRef$current = linkInputRef.current) === null || _linkInputRef$current === void 0 ? void 0 : _linkInputRef$current.focus();
|
|
281
|
+
}
|
|
275
282
|
return dispatch({
|
|
276
283
|
invalidUrl: true
|
|
277
284
|
});
|
|
@@ -377,12 +384,15 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
377
384
|
}, chunk)
|
|
378
385
|
}
|
|
379
386
|
})) : intl.formatMessage(formMessages.linkInvalid) : null;
|
|
380
|
-
return /*#__PURE__*/React.createElement("form", {
|
|
387
|
+
return /*#__PURE__*/React.createElement("form", _extends({
|
|
381
388
|
"data-testid": testIds.linkPicker,
|
|
382
389
|
// Use onSubmitCapture instead of onSubmit so that any possible parent form isn't submitted
|
|
383
|
-
onSubmitCapture: handleSubmit
|
|
390
|
+
onSubmitCapture: handleSubmit
|
|
391
|
+
}, fg('navx-4104-link-picker-a11y-focus-states') ? {
|
|
392
|
+
noValidate: true
|
|
393
|
+
} : {}, {
|
|
384
394
|
className: ax(["_19bv164s _u5f31pah _ca0q1k79 _n3td1t3k _vchhusvi _1e0ctcjq"])
|
|
385
|
-
}, /*#__PURE__*/React.createElement(TrackMount, null), submitOnInputChange && /*#__PURE__*/React.createElement(AutoSubmitOnChange, {
|
|
395
|
+
}), /*#__PURE__*/React.createElement(TrackMount, null), submitOnInputChange && /*#__PURE__*/React.createElement(AutoSubmitOnChange, {
|
|
386
396
|
url: url,
|
|
387
397
|
isSubmitting: isSubmitting,
|
|
388
398
|
isSelectedItem: isSelectedItem,
|
|
@@ -404,14 +414,17 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
404
414
|
value: url,
|
|
405
415
|
autoFocus: true,
|
|
406
416
|
clearLabel: intl.formatMessage(formMessages.clearLink),
|
|
407
|
-
error: errorMessage || additionalError
|
|
417
|
+
error: errorMessage || additionalError
|
|
418
|
+
}, fg('navx-4104-link-picker-a11y-focus-states') ? {
|
|
419
|
+
validationMessage: intl.formatMessage(formMessages.linkInvalid)
|
|
420
|
+
} : {}, {
|
|
408
421
|
spotlightTargetName: "link-picker-search-field-spotlight-target",
|
|
409
422
|
"aria-readonly": isSubmitting
|
|
410
423
|
}, a11yList, {
|
|
411
424
|
onClear: handleUrlClear,
|
|
412
425
|
onKeyDown: handleKeyDown,
|
|
413
426
|
onChange: handleChangeUrl,
|
|
414
|
-
inputRef: inputRef,
|
|
427
|
+
inputRef: fg('navx-4104-link-picker-a11y-focus-states') ? mergedRefs : inputRef,
|
|
415
428
|
isRequired: true
|
|
416
429
|
})), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, {
|
|
417
430
|
autoComplete: "off",
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -5,27 +5,17 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import { abortUfoExperience, startUfoExperience, ufoExperience } from '../../common/analytics/experiences';
|
|
6
6
|
export var INIT_CONTEXT = 'SESSION_UNINITIALIZED';
|
|
7
7
|
export var SessionContext = /*#__PURE__*/createContext(INIT_CONTEXT);
|
|
8
|
-
var useConstructor = function useConstructor(callback) {
|
|
9
|
-
var hasBeenFired = useRef(false);
|
|
10
|
-
if (!hasBeenFired.current) {
|
|
11
|
-
callback();
|
|
12
|
-
hasBeenFired.current = true;
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
8
|
export var LinkPickerSessionProvider = function LinkPickerSessionProvider(_ref) {
|
|
17
9
|
var children = _ref.children;
|
|
18
10
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
19
11
|
var _useRef = useRef(uuidv4()),
|
|
20
12
|
sessionId = _useRef.current;
|
|
21
13
|
useEffect(function () {
|
|
14
|
+
startUfoExperience(ufoExperience.mounted, sessionId);
|
|
22
15
|
return function () {
|
|
23
16
|
return abortUfoExperience(ufoExperience.mounted, sessionId);
|
|
24
17
|
};
|
|
25
18
|
}, [sessionId]);
|
|
26
|
-
useConstructor(function () {
|
|
27
|
-
return startUfoExperience(ufoExperience.mounted, sessionId);
|
|
28
|
-
});
|
|
29
19
|
return /*#__PURE__*/React.createElement(SessionContext.Provider, {
|
|
30
20
|
value: sessionId
|
|
31
21
|
}, children);
|
|
@@ -51,20 +51,20 @@ export function usePlugins(state, activeTab, plugins, recentSearchListSize, alwa
|
|
|
51
51
|
cancel = _resolvePluginUpdates.cancel;
|
|
52
52
|
var updateResults = /*#__PURE__*/function () {
|
|
53
53
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
54
|
-
var _isLoading, _yield$next, value, done;
|
|
55
|
-
return _regeneratorRuntime.wrap(function
|
|
54
|
+
var _isLoading, _yield$next, value, done, _t;
|
|
55
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
56
56
|
while (1) switch (_context.prev = _context.next) {
|
|
57
57
|
case 0:
|
|
58
58
|
_context.prev = 0;
|
|
59
59
|
_isLoading = true;
|
|
60
|
-
case
|
|
60
|
+
case 1:
|
|
61
61
|
if (!_isLoading) {
|
|
62
|
-
_context.next =
|
|
62
|
+
_context.next = 3;
|
|
63
63
|
break;
|
|
64
64
|
}
|
|
65
|
-
_context.next =
|
|
65
|
+
_context.next = 2;
|
|
66
66
|
return next();
|
|
67
|
-
case
|
|
67
|
+
case 2:
|
|
68
68
|
_yield$next = _context.sent;
|
|
69
69
|
value = _yield$next.value;
|
|
70
70
|
done = _yield$next.done;
|
|
@@ -76,28 +76,28 @@ export function usePlugins(state, activeTab, plugins, recentSearchListSize, alwa
|
|
|
76
76
|
isLoading: !done
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
_context.next =
|
|
79
|
+
_context.next = 1;
|
|
80
80
|
break;
|
|
81
|
-
case
|
|
82
|
-
_context.next =
|
|
81
|
+
case 3:
|
|
82
|
+
_context.next = 5;
|
|
83
83
|
break;
|
|
84
|
-
case
|
|
85
|
-
_context.prev =
|
|
86
|
-
|
|
87
|
-
if (!(
|
|
84
|
+
case 4:
|
|
85
|
+
_context.prev = 4;
|
|
86
|
+
_t = _context["catch"](0);
|
|
87
|
+
if (!(_t instanceof CancellationError)) {
|
|
88
88
|
dispatch({
|
|
89
89
|
type: 'ERROR',
|
|
90
|
-
payload:
|
|
90
|
+
payload: _t
|
|
91
91
|
});
|
|
92
92
|
createAnalyticsEvent(createEventPayload('operational.resultsResolve.failed', {
|
|
93
|
-
error: convertToError(
|
|
93
|
+
error: convertToError(_t).toString()
|
|
94
94
|
})).fire(ANALYTICS_CHANNEL);
|
|
95
95
|
}
|
|
96
|
-
case
|
|
96
|
+
case 5:
|
|
97
97
|
case "end":
|
|
98
98
|
return _context.stop();
|
|
99
99
|
}
|
|
100
|
-
}, _callee, null, [[0,
|
|
100
|
+
}, _callee, null, [[0, 4]]);
|
|
101
101
|
}));
|
|
102
102
|
return function updateResults() {
|
|
103
103
|
return _ref.apply(this, arguments);
|
|
@@ -45,18 +45,19 @@ export var resolvePluginUpdates = function resolvePluginUpdates(plugin, state) {
|
|
|
45
45
|
cancel: cancel,
|
|
46
46
|
next: function () {
|
|
47
47
|
var _next = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
|
-
|
|
48
|
+
var _t;
|
|
49
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
49
50
|
while (1) switch (_context.prev = _context.next) {
|
|
50
51
|
case 0:
|
|
51
|
-
_context.next =
|
|
52
|
+
_context.next = 1;
|
|
52
53
|
return promise;
|
|
53
|
-
case
|
|
54
|
-
|
|
54
|
+
case 1:
|
|
55
|
+
_t = _context.sent;
|
|
55
56
|
return _context.abrupt("return", {
|
|
56
|
-
value:
|
|
57
|
+
value: _t,
|
|
57
58
|
done: true
|
|
58
59
|
});
|
|
59
|
-
case
|
|
60
|
+
case 2:
|
|
60
61
|
case "end":
|
|
61
62
|
return _context.stop();
|
|
62
63
|
}
|
|
@@ -4,19 +4,20 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
import "./index.compiled.css";
|
|
7
|
-
import * as React from 'react';
|
|
8
7
|
import { ax, ix } from "@compiled/react/runtime";
|
|
9
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
11
|
+
import React, { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
13
12
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
13
|
+
import { useMergeRefs } from 'use-callback-ref';
|
|
14
14
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
15
15
|
import uuid from 'uuid';
|
|
16
16
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
17
17
|
import { CardClient } from '@atlaskit/link-provider';
|
|
18
18
|
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
19
19
|
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
20
|
+
import { fg } from "@atlaskit/platform-feature-flags";
|
|
20
21
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
21
22
|
import LinkUrl from '@atlaskit/smart-card/link-url';
|
|
22
23
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -112,6 +113,8 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
112
113
|
alwaysShowTabs = _ref.alwaysShowTabs;
|
|
113
114
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
114
115
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
116
|
+
var linkInputRef = React.useRef(null);
|
|
117
|
+
var mergedRefs = useMergeRefs(inputRef ? [linkInputRef, inputRef] : [linkInputRef]);
|
|
115
118
|
var _useReducer = useReducer(reducer, _objectSpread(_objectSpread({}, initState), {}, {
|
|
116
119
|
url: normalizeUrl(initUrl) || '',
|
|
117
120
|
displayText: initDisplayText || ''
|
|
@@ -239,71 +242,74 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
239
242
|
}, [dispatch]);
|
|
240
243
|
var handleSubmit = useCallback( /*#__PURE__*/function () {
|
|
241
244
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
242
|
-
var normalized, urlResponse, responseObject;
|
|
243
|
-
return _regeneratorRuntime.wrap(function
|
|
245
|
+
var normalized, urlResponse, responseObject, _linkInputRef$current, _t;
|
|
246
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
244
247
|
while (1) switch (_context.prev = _context.next) {
|
|
245
248
|
case 0:
|
|
246
249
|
event === null || event === void 0 || event.preventDefault();
|
|
247
250
|
if (!isSubmitting) {
|
|
248
|
-
_context.next =
|
|
251
|
+
_context.next = 1;
|
|
249
252
|
break;
|
|
250
253
|
}
|
|
251
254
|
return _context.abrupt("return");
|
|
252
|
-
case
|
|
255
|
+
case 1:
|
|
253
256
|
if (!(isSelectedItem && selectedItem)) {
|
|
254
|
-
_context.next =
|
|
257
|
+
_context.next = 2;
|
|
255
258
|
break;
|
|
256
259
|
}
|
|
257
260
|
return _context.abrupt("return", handleInsert(selectedItem.url, selectedItem.name, 'typeAhead'));
|
|
258
|
-
case
|
|
261
|
+
case 2:
|
|
259
262
|
normalized = normalizeUrl(url);
|
|
260
263
|
if (!normalized) {
|
|
261
|
-
_context.next =
|
|
264
|
+
_context.next = 10;
|
|
262
265
|
break;
|
|
263
266
|
}
|
|
264
267
|
if (!previewableLinksOnly) {
|
|
265
|
-
_context.next =
|
|
268
|
+
_context.next = 9;
|
|
266
269
|
break;
|
|
267
270
|
}
|
|
268
|
-
_context.prev =
|
|
269
|
-
_context.next =
|
|
271
|
+
_context.prev = 3;
|
|
272
|
+
_context.next = 4;
|
|
270
273
|
return client.fetchData(normalized);
|
|
271
|
-
case
|
|
274
|
+
case 4:
|
|
272
275
|
urlResponse = _context.sent;
|
|
273
276
|
responseObject = urlResponse === null || urlResponse === void 0 ? void 0 : urlResponse.data;
|
|
274
277
|
if (!(responseObject && 'preview' in responseObject)) {
|
|
275
|
-
_context.next =
|
|
278
|
+
_context.next = 5;
|
|
276
279
|
break;
|
|
277
280
|
}
|
|
278
281
|
return _context.abrupt("return", handleInsert(normalized, null, 'manual'));
|
|
279
|
-
case
|
|
282
|
+
case 5:
|
|
280
283
|
return _context.abrupt("return", dispatch({
|
|
281
284
|
invalidUrl: true,
|
|
282
285
|
hasPreview: false
|
|
283
286
|
}));
|
|
284
|
-
case
|
|
285
|
-
_context.next =
|
|
287
|
+
case 6:
|
|
288
|
+
_context.next = 8;
|
|
286
289
|
break;
|
|
287
|
-
case
|
|
288
|
-
_context.prev =
|
|
289
|
-
|
|
290
|
+
case 7:
|
|
291
|
+
_context.prev = 7;
|
|
292
|
+
_t = _context["catch"](3);
|
|
290
293
|
return _context.abrupt("return", dispatch({
|
|
291
294
|
invalidUrl: true
|
|
292
295
|
}));
|
|
293
|
-
case
|
|
294
|
-
_context.next =
|
|
296
|
+
case 8:
|
|
297
|
+
_context.next = 10;
|
|
295
298
|
break;
|
|
296
|
-
case
|
|
299
|
+
case 9:
|
|
297
300
|
return _context.abrupt("return", handleInsert(normalized, null, 'manual'));
|
|
298
|
-
case
|
|
301
|
+
case 10:
|
|
302
|
+
if (fg('navx-4104-link-picker-a11y-focus-states')) {
|
|
303
|
+
(_linkInputRef$current = linkInputRef.current) === null || _linkInputRef$current === void 0 || _linkInputRef$current.focus();
|
|
304
|
+
}
|
|
299
305
|
return _context.abrupt("return", dispatch({
|
|
300
306
|
invalidUrl: true
|
|
301
307
|
}));
|
|
302
|
-
case
|
|
308
|
+
case 11:
|
|
303
309
|
case "end":
|
|
304
310
|
return _context.stop();
|
|
305
311
|
}
|
|
306
|
-
}, _callee, null, [[
|
|
312
|
+
}, _callee, null, [[3, 7]]);
|
|
307
313
|
}));
|
|
308
314
|
return function (_x) {
|
|
309
315
|
return _ref2.apply(this, arguments);
|
|
@@ -414,12 +420,15 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
414
420
|
}
|
|
415
421
|
}
|
|
416
422
|
})) : intl.formatMessage(formMessages.linkInvalid) : null;
|
|
417
|
-
return /*#__PURE__*/React.createElement("form", {
|
|
423
|
+
return /*#__PURE__*/React.createElement("form", _extends({
|
|
418
424
|
"data-testid": testIds.linkPicker,
|
|
419
425
|
// Use onSubmitCapture instead of onSubmit so that any possible parent form isn't submitted
|
|
420
|
-
onSubmitCapture: handleSubmit
|
|
426
|
+
onSubmitCapture: handleSubmit
|
|
427
|
+
}, fg('navx-4104-link-picker-a11y-focus-states') ? {
|
|
428
|
+
noValidate: true
|
|
429
|
+
} : {}, {
|
|
421
430
|
className: ax(["_19bv164s _u5f31pah _ca0q1k79 _n3td1t3k _vchhusvi _1e0ctcjq"])
|
|
422
|
-
}, /*#__PURE__*/React.createElement(TrackMount, null), submitOnInputChange && /*#__PURE__*/React.createElement(AutoSubmitOnChange, {
|
|
431
|
+
}), /*#__PURE__*/React.createElement(TrackMount, null), submitOnInputChange && /*#__PURE__*/React.createElement(AutoSubmitOnChange, {
|
|
423
432
|
url: url,
|
|
424
433
|
isSubmitting: isSubmitting,
|
|
425
434
|
isSelectedItem: isSelectedItem,
|
|
@@ -441,14 +450,17 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
441
450
|
value: url,
|
|
442
451
|
autoFocus: true,
|
|
443
452
|
clearLabel: intl.formatMessage(formMessages.clearLink),
|
|
444
|
-
error: errorMessage || additionalError
|
|
453
|
+
error: errorMessage || additionalError
|
|
454
|
+
}, fg('navx-4104-link-picker-a11y-focus-states') ? {
|
|
455
|
+
validationMessage: intl.formatMessage(formMessages.linkInvalid)
|
|
456
|
+
} : {}, {
|
|
445
457
|
spotlightTargetName: "link-picker-search-field-spotlight-target",
|
|
446
458
|
"aria-readonly": isSubmitting
|
|
447
459
|
}, a11yList, {
|
|
448
460
|
onClear: handleUrlClear,
|
|
449
461
|
onKeyDown: handleKeyDown,
|
|
450
462
|
onChange: handleChangeUrl,
|
|
451
|
-
inputRef: inputRef,
|
|
463
|
+
inputRef: fg('navx-4104-link-picker-a11y-focus-states') ? mergedRefs : inputRef,
|
|
452
464
|
isRequired: true
|
|
453
465
|
})), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, {
|
|
454
466
|
autoComplete: "off",
|
package/dist/esm/ui/main.js
CHANGED
package/dist/esm/ui/messages-provider/lazy-messages-provider/utils/fetch-messages-for-locale.js
CHANGED
|
@@ -3,50 +3,50 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import { locales } from '../../../../i18n';
|
|
4
4
|
export var fetchMessagesForLocale = /*#__PURE__*/function () {
|
|
5
5
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(locale) {
|
|
6
|
-
var localeKey, messages, parentLocale, _messages;
|
|
7
|
-
return _regeneratorRuntime.wrap(function
|
|
6
|
+
var localeKey, messages, parentLocale, _messages, _t, _t2;
|
|
7
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
8
8
|
while (1) switch (_context.prev = _context.next) {
|
|
9
9
|
case 0:
|
|
10
10
|
_context.prev = 0;
|
|
11
11
|
localeKey = locale.replace('-', '_');
|
|
12
12
|
if (!(localeKey in locales)) {
|
|
13
|
-
_context.next =
|
|
13
|
+
_context.next = 2;
|
|
14
14
|
break;
|
|
15
15
|
}
|
|
16
|
-
_context.next =
|
|
16
|
+
_context.next = 1;
|
|
17
17
|
return locales[localeKey]();
|
|
18
|
-
case
|
|
18
|
+
case 1:
|
|
19
19
|
messages = _context.sent;
|
|
20
20
|
return _context.abrupt("return", messages.default);
|
|
21
|
-
case
|
|
22
|
-
_context.next =
|
|
21
|
+
case 2:
|
|
22
|
+
_context.next = 4;
|
|
23
23
|
break;
|
|
24
|
-
case
|
|
25
|
-
_context.prev =
|
|
26
|
-
|
|
27
|
-
case
|
|
28
|
-
_context.prev =
|
|
24
|
+
case 3:
|
|
25
|
+
_context.prev = 3;
|
|
26
|
+
_t = _context["catch"](0);
|
|
27
|
+
case 4:
|
|
28
|
+
_context.prev = 4;
|
|
29
29
|
parentLocale = locale.split(/[-_]/)[0];
|
|
30
30
|
if (!(parentLocale in locales)) {
|
|
31
|
-
_context.next =
|
|
31
|
+
_context.next = 6;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
|
-
_context.next =
|
|
34
|
+
_context.next = 5;
|
|
35
35
|
return locales[parentLocale]();
|
|
36
|
-
case
|
|
36
|
+
case 5:
|
|
37
37
|
_messages = _context.sent;
|
|
38
38
|
return _context.abrupt("return", _messages.default);
|
|
39
|
-
case
|
|
40
|
-
_context.next =
|
|
39
|
+
case 6:
|
|
40
|
+
_context.next = 8;
|
|
41
41
|
break;
|
|
42
|
-
case
|
|
43
|
-
_context.prev =
|
|
44
|
-
|
|
45
|
-
case
|
|
42
|
+
case 7:
|
|
43
|
+
_context.prev = 7;
|
|
44
|
+
_t2 = _context["catch"](4);
|
|
45
|
+
case 8:
|
|
46
46
|
case "end":
|
|
47
47
|
return _context.stop();
|
|
48
48
|
}
|
|
49
|
-
}, _callee, null, [[0,
|
|
49
|
+
}, _callee, null, [[0, 3], [4, 7]]);
|
|
50
50
|
}));
|
|
51
51
|
return function fetchMessagesForLocale(_x) {
|
|
52
52
|
return _ref.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
},
|
|
45
45
|
"aifc_create_enabled": {
|
|
46
46
|
"type": "boolean"
|
|
47
|
+
},
|
|
48
|
+
"navx-4104-link-picker-a11y-focus-states": {
|
|
49
|
+
"type": "boolean"
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
"scripts": {
|
|
@@ -58,20 +61,20 @@
|
|
|
58
61
|
"@atlaskit/form": "^15.5.0",
|
|
59
62
|
"@atlaskit/frontend-utilities": "^3.3.0",
|
|
60
63
|
"@atlaskit/heading": "^5.4.0",
|
|
61
|
-
"@atlaskit/icon": "^35.
|
|
64
|
+
"@atlaskit/icon": "^35.3.0",
|
|
62
65
|
"@atlaskit/intl-messages-provider": "^3.3.0",
|
|
63
66
|
"@atlaskit/link": "^3.4.0",
|
|
64
67
|
"@atlaskit/link-provider": "^4.4.0",
|
|
65
|
-
"@atlaskit/linking-common": "^9.
|
|
68
|
+
"@atlaskit/linking-common": "^9.12.0",
|
|
66
69
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
67
70
|
"@atlaskit/primitives": "^19.0.0",
|
|
68
|
-
"@atlaskit/smart-card": "^44.
|
|
71
|
+
"@atlaskit/smart-card": "^44.18.0",
|
|
69
72
|
"@atlaskit/spinner": "^19.1.0",
|
|
70
|
-
"@atlaskit/spotlight": "^0.
|
|
73
|
+
"@atlaskit/spotlight": "^0.15.0",
|
|
71
74
|
"@atlaskit/tabs": "^19.1.0",
|
|
72
75
|
"@atlaskit/textfield": "^8.3.0",
|
|
73
|
-
"@atlaskit/tokens": "^13.
|
|
74
|
-
"@atlaskit/tooltip": "^22.
|
|
76
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
77
|
+
"@atlaskit/tooltip": "^22.5.0",
|
|
75
78
|
"@atlaskit/ufo": "^0.5.0",
|
|
76
79
|
"@atlaskit/visually-hidden": "^3.1.0",
|
|
77
80
|
"@babel/runtime": "^7.0.0",
|
|
@@ -91,8 +94,8 @@
|
|
|
91
94
|
"@af/analytics-codegen": "workspace:^",
|
|
92
95
|
"@af/integration-testing": "workspace:^",
|
|
93
96
|
"@af/visual-regression": "workspace:^",
|
|
94
|
-
"@atlaskit/dropdown-menu": "^16.
|
|
95
|
-
"@atlaskit/link-test-helpers": "^10.
|
|
97
|
+
"@atlaskit/dropdown-menu": "^16.10.0",
|
|
98
|
+
"@atlaskit/link-test-helpers": "^10.4.0",
|
|
96
99
|
"@atlassian/a11y-jest-testing": "^0.11.0",
|
|
97
100
|
"@atlassian/a11y-playwright-testing": "^0.10.0",
|
|
98
101
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|