@atlaskit/link-picker 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/ui/index.js +15 -4
- package/dist/cjs/ui/link-picker/index.js +151 -81
- package/dist/cjs/ui/link-picker/styled.js +6 -4
- package/dist/cjs/ui/loader-fallback/index.js +24 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/ui/index.js +8 -2
- package/dist/es2019/ui/link-picker/index.js +46 -20
- package/dist/es2019/ui/link-picker/styled.js +6 -0
- package/dist/es2019/ui/loader-fallback/index.js +11 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/ui/index.js +10 -2
- package/dist/esm/ui/link-picker/index.js +145 -77
- package/dist/esm/ui/link-picker/styled.js +4 -3
- package/dist/esm/ui/loader-fallback/index.js +11 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/ui/link-picker/index.d.ts +3 -2
- package/dist/types/ui/link-picker/styled.d.ts +1 -0
- package/dist/types/ui/loader-fallback/index.d.ts +3 -0
- package/dist/types/ui/types.d.ts +4 -0
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/link-picker
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3b5e61f9b3b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3b5e61f9b3b) - [ux] Adds in TAB UI support for Link Picker
|
|
8
|
+
|
|
9
|
+
## 1.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`0ddad39a369`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0ddad39a369) - [ux] Lazy load the link-picker instead. The lazily loaded picker is now the default that's exported
|
|
14
|
+
|
|
15
|
+
## 1.2.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`d17b35d4c20`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d17b35d4c20) - Display validation message when submitting empty input
|
|
20
|
+
|
|
3
21
|
## 1.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/cjs/ui/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.ComposedLinkPicker = void 0;
|
|
9
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
13
15
|
|
|
16
|
+
var _reactLooselyLazy = require("react-loosely-lazy");
|
|
17
|
+
|
|
14
18
|
var _version = require("../version.json");
|
|
15
19
|
|
|
16
20
|
var _errorBoundaryFallback = require("./error-boundary-fallback");
|
|
17
21
|
|
|
18
|
-
var
|
|
22
|
+
var _loaderFallback = require("./loader-fallback");
|
|
19
23
|
|
|
20
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
25
|
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2.default)(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
27
|
|
|
24
28
|
var COMPONENT_NAME = 'LinkPicker';
|
|
25
29
|
var ANALYTICS_CHANNEL = 'media';
|
|
@@ -28,11 +32,18 @@ var PACKAGE_DATA = {
|
|
|
28
32
|
packageVersion: _version.version,
|
|
29
33
|
componentName: COMPONENT_NAME
|
|
30
34
|
};
|
|
35
|
+
var LazyLinkPicker = (0, _reactLooselyLazy.lazyForPaint)(function () {
|
|
36
|
+
return Promise.resolve().then(function () {
|
|
37
|
+
return _interopRequireWildcard(require('./link-picker'));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
31
40
|
var ComposedLinkPicker = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
32
41
|
return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsErrorBoundary, {
|
|
33
42
|
channel: ANALYTICS_CHANNEL,
|
|
34
43
|
data: PACKAGE_DATA,
|
|
35
44
|
ErrorComponent: _errorBoundaryFallback.ErrorBoundaryFallback
|
|
36
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_reactLooselyLazy.LazySuspense, {
|
|
46
|
+
fallback: _loaderFallback.LoaderFallback
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement(LazyLinkPicker, props)));
|
|
37
48
|
});
|
|
38
49
|
exports.ComposedLinkPicker = ComposedLinkPicker;
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.default = exports.RECENT_SEARCH_LIST_SIZE = void 0;
|
|
11
11
|
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
13
|
|
|
14
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
|
+
|
|
14
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
17
|
|
|
16
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -33,6 +35,8 @@ var _react2 = require("@emotion/react");
|
|
|
33
35
|
|
|
34
36
|
var _reactIntlNext = require("react-intl-next");
|
|
35
37
|
|
|
38
|
+
var _tabs = _interopRequireWildcard(require("@atlaskit/tabs"));
|
|
39
|
+
|
|
36
40
|
var _messages = require("./messages");
|
|
37
41
|
|
|
38
42
|
var _textInput = _interopRequireDefault(require("./text-input"));
|
|
@@ -61,7 +65,7 @@ var _linkSearchNoResults = _interopRequireDefault(require("./link-search-no-resu
|
|
|
61
65
|
|
|
62
66
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
63
67
|
|
|
64
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
68
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
65
69
|
|
|
66
70
|
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; }
|
|
67
71
|
|
|
@@ -160,6 +164,19 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
160
164
|
return [name, container, formattedDate].filter(Boolean).join(', ');
|
|
161
165
|
}
|
|
162
166
|
});
|
|
167
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTabs", function () {
|
|
168
|
+
if (_this.props.plugins && _this.props.plugins.length > 1) {
|
|
169
|
+
return _this.props.plugins.filter(function (plugin) {
|
|
170
|
+
return !!plugin.tabTitle;
|
|
171
|
+
}).map(function (plugin) {
|
|
172
|
+
return {
|
|
173
|
+
tabTitle: plugin.tabTitle
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return [];
|
|
179
|
+
});
|
|
163
180
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isUrlPopulatedWithSelectedItem", function () {
|
|
164
181
|
/**
|
|
165
182
|
* When we use ArrowKey to navigate through result items,
|
|
@@ -243,24 +260,22 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
243
260
|
url = _this$state5.url,
|
|
244
261
|
selectedIndex = _this$state5.selectedIndex,
|
|
245
262
|
items = _this$state5.items;
|
|
263
|
+
var intl = _this.props.intl;
|
|
246
264
|
var selectedItem = items[selectedIndex];
|
|
247
265
|
|
|
248
266
|
if (_this.isUrlPopulatedWithSelectedItem()) {
|
|
249
|
-
_this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
250
|
-
} else if (url.length > 0) {
|
|
251
|
-
var normalized = (0, _url.normalizeUrl)(url);
|
|
252
|
-
|
|
253
|
-
if (normalized) {
|
|
254
|
-
_this.handleInsert(normalized, null, 'manual');
|
|
255
|
-
} else {
|
|
256
|
-
var intl = _this.props.intl;
|
|
257
|
-
var linkInvalid = intl.formatMessage(_messages.messages.linkInvalid);
|
|
258
|
-
|
|
259
|
-
_this.setState({
|
|
260
|
-
invalidUrl: linkInvalid
|
|
261
|
-
});
|
|
262
|
-
}
|
|
267
|
+
return _this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
263
268
|
}
|
|
269
|
+
|
|
270
|
+
var normalized = (0, _url.normalizeUrl)(url);
|
|
271
|
+
|
|
272
|
+
if (normalized) {
|
|
273
|
+
return _this.handleInsert(normalized, null, 'manual');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return _this.setState({
|
|
277
|
+
invalidUrl: intl.formatMessage(_messages.messages.linkInvalid)
|
|
278
|
+
});
|
|
264
279
|
});
|
|
265
280
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleKeyDown", function (event) {
|
|
266
281
|
var _this$state6 = _this.state,
|
|
@@ -319,7 +334,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
319
334
|
url: (0, _url.normalizeUrl)(props.url) || '',
|
|
320
335
|
displayText: props.displayText || '',
|
|
321
336
|
items: [],
|
|
322
|
-
invalidUrl: null
|
|
337
|
+
invalidUrl: null,
|
|
338
|
+
activePlugin: 0
|
|
323
339
|
};
|
|
324
340
|
/* Cache functions */
|
|
325
341
|
|
|
@@ -349,7 +365,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
349
365
|
return null;
|
|
350
366
|
}
|
|
351
367
|
|
|
352
|
-
return this.props.plugins[
|
|
368
|
+
return this.props.plugins[this.state.activePlugin];
|
|
353
369
|
}
|
|
354
370
|
/**
|
|
355
371
|
* Interface between link picker and plugins to update results
|
|
@@ -359,21 +375,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
359
375
|
key: "updateResults",
|
|
360
376
|
value: function () {
|
|
361
377
|
var _updateResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
362
|
-
var
|
|
378
|
+
var _this2 = this;
|
|
363
379
|
|
|
364
|
-
|
|
380
|
+
var queryVersion, activePlugin, updates, _loop, _ret;
|
|
381
|
+
|
|
382
|
+
return _regenerator.default.wrap(function _callee2$(_context3) {
|
|
365
383
|
while (1) {
|
|
366
|
-
switch (
|
|
384
|
+
switch (_context3.prev = _context3.next) {
|
|
367
385
|
case 0:
|
|
368
386
|
queryVersion = ++this.queryVersion;
|
|
369
387
|
activePlugin = this.getActivePlugin();
|
|
370
388
|
|
|
371
389
|
if (activePlugin) {
|
|
372
|
-
|
|
390
|
+
_context3.next = 4;
|
|
373
391
|
break;
|
|
374
392
|
}
|
|
375
393
|
|
|
376
|
-
return
|
|
394
|
+
return _context3.abrupt("return");
|
|
377
395
|
|
|
378
396
|
case 4:
|
|
379
397
|
updates = activePlugin.resolve({
|
|
@@ -383,82 +401,114 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
383
401
|
isLoading: true,
|
|
384
402
|
items: []
|
|
385
403
|
});
|
|
386
|
-
|
|
404
|
+
_context3.prev = 6;
|
|
405
|
+
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
406
|
+
var done, value, _result$done, result;
|
|
407
|
+
|
|
408
|
+
return _regenerator.default.wrap(function _loop$(_context2) {
|
|
409
|
+
while (1) {
|
|
410
|
+
switch (_context2.prev = _context2.next) {
|
|
411
|
+
case 0:
|
|
412
|
+
done = false;
|
|
413
|
+
value = void 0;
|
|
414
|
+
|
|
415
|
+
if (!(updates instanceof Promise)) {
|
|
416
|
+
_context2.next = 9;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
done = true;
|
|
421
|
+
_context2.next = 6;
|
|
422
|
+
return updates;
|
|
423
|
+
|
|
424
|
+
case 6:
|
|
425
|
+
value = _context2.sent;
|
|
426
|
+
_context2.next = 14;
|
|
427
|
+
break;
|
|
428
|
+
|
|
429
|
+
case 9:
|
|
430
|
+
_context2.next = 11;
|
|
431
|
+
return updates.next();
|
|
432
|
+
|
|
433
|
+
case 11:
|
|
434
|
+
result = _context2.sent;
|
|
435
|
+
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
436
|
+
value = result.value;
|
|
437
|
+
|
|
438
|
+
case 14:
|
|
439
|
+
if (!(queryVersion !== _this2.queryVersion)) {
|
|
440
|
+
_context2.next = 16;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return _context2.abrupt("return", {
|
|
445
|
+
v: void 0
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
case 16:
|
|
449
|
+
_this2.setState(function (prev) {
|
|
450
|
+
return {
|
|
451
|
+
items: limit(value.data),
|
|
452
|
+
isLoading: !done
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
if (!done) {
|
|
457
|
+
_context2.next = 19;
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return _context2.abrupt("return", {
|
|
462
|
+
v: void 0
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
case 19:
|
|
466
|
+
case "end":
|
|
467
|
+
return _context2.stop();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}, _loop);
|
|
471
|
+
});
|
|
387
472
|
|
|
388
|
-
case
|
|
473
|
+
case 8:
|
|
389
474
|
if (!(queryVersion === this.queryVersion)) {
|
|
390
|
-
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
done = false;
|
|
395
|
-
value = void 0;
|
|
396
|
-
|
|
397
|
-
if (!(updates instanceof Promise)) {
|
|
398
|
-
_context2.next = 17;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
done = true;
|
|
403
|
-
_context2.next = 14;
|
|
404
|
-
return updates;
|
|
405
|
-
|
|
406
|
-
case 14:
|
|
407
|
-
value = _context2.sent;
|
|
408
|
-
_context2.next = 22;
|
|
409
|
-
break;
|
|
410
|
-
|
|
411
|
-
case 17:
|
|
412
|
-
_context2.next = 19;
|
|
413
|
-
return updates.next();
|
|
414
|
-
|
|
415
|
-
case 19:
|
|
416
|
-
result = _context2.sent;
|
|
417
|
-
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
418
|
-
value = result.value;
|
|
419
|
-
|
|
420
|
-
case 22:
|
|
421
|
-
if (!(queryVersion !== this.queryVersion)) {
|
|
422
|
-
_context2.next = 24;
|
|
475
|
+
_context3.next = 15;
|
|
423
476
|
break;
|
|
424
477
|
}
|
|
425
478
|
|
|
426
|
-
return
|
|
479
|
+
return _context3.delegateYield(_loop(), "t0", 10);
|
|
427
480
|
|
|
428
|
-
case
|
|
429
|
-
|
|
430
|
-
items: limit(value.data),
|
|
431
|
-
isLoading: !done
|
|
432
|
-
});
|
|
481
|
+
case 10:
|
|
482
|
+
_ret = _context3.t0;
|
|
433
483
|
|
|
434
|
-
if (!
|
|
435
|
-
|
|
484
|
+
if (!((0, _typeof2.default)(_ret) === "object")) {
|
|
485
|
+
_context3.next = 13;
|
|
436
486
|
break;
|
|
437
487
|
}
|
|
438
488
|
|
|
439
|
-
return
|
|
489
|
+
return _context3.abrupt("return", _ret.v);
|
|
440
490
|
|
|
441
|
-
case
|
|
442
|
-
|
|
491
|
+
case 13:
|
|
492
|
+
_context3.next = 8;
|
|
443
493
|
break;
|
|
444
494
|
|
|
445
|
-
case
|
|
446
|
-
|
|
495
|
+
case 15:
|
|
496
|
+
_context3.next = 20;
|
|
447
497
|
break;
|
|
448
498
|
|
|
449
|
-
case
|
|
450
|
-
|
|
451
|
-
|
|
499
|
+
case 17:
|
|
500
|
+
_context3.prev = 17;
|
|
501
|
+
_context3.t1 = _context3["catch"](6);
|
|
452
502
|
this.setState({
|
|
453
503
|
isLoading: false
|
|
454
504
|
});
|
|
455
505
|
|
|
456
|
-
case
|
|
506
|
+
case 20:
|
|
457
507
|
case "end":
|
|
458
|
-
return
|
|
508
|
+
return _context3.stop();
|
|
459
509
|
}
|
|
460
510
|
}
|
|
461
|
-
}, _callee2, this, [[6,
|
|
511
|
+
}, _callee2, this, [[6, 17]]);
|
|
462
512
|
}));
|
|
463
513
|
|
|
464
514
|
function updateResults() {
|
|
@@ -470,6 +520,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
470
520
|
}, {
|
|
471
521
|
key: "render",
|
|
472
522
|
value: function render() {
|
|
523
|
+
var _this3 = this;
|
|
524
|
+
|
|
473
525
|
var _this$state7 = this.state,
|
|
474
526
|
items = _this$state7.items,
|
|
475
527
|
isLoading = _this$state7.isLoading,
|
|
@@ -480,6 +532,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
480
532
|
displayText = _this$state7.displayText;
|
|
481
533
|
var formatMessage = this.props.intl.formatMessage;
|
|
482
534
|
var activePlugin = this.getActivePlugin();
|
|
535
|
+
var tabs = this.getTabs();
|
|
483
536
|
var linkPlaceHolder = formatMessage(activePlugin ? _messages.messages.placeholder : _messages.messages.linkPlaceholder);
|
|
484
537
|
var linkLabel = formatMessage(_messages.messages.linkLabel);
|
|
485
538
|
var linkTextLabel = formatMessage(_messages.messages.linkTextLabel);
|
|
@@ -502,7 +555,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
502
555
|
return (0, _react2.jsx)("div", {
|
|
503
556
|
"data-testid": "link-picker",
|
|
504
557
|
css: _styled.rootContainerStyles
|
|
505
|
-
},
|
|
558
|
+
}, tabs.length > 0 && (0, _react2.jsx)(_tabs.default, {
|
|
559
|
+
id: "link-picker-tabs",
|
|
560
|
+
testId: "link-picker-tabs",
|
|
561
|
+
onChange: function onChange(activePlugin) {
|
|
562
|
+
return _this3.setState({
|
|
563
|
+
activePlugin: activePlugin
|
|
564
|
+
}, function () {
|
|
565
|
+
_this3.updateResults();
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}, (0, _react2.jsx)(_tabs.TabList, null, tabs.map(function (tab) {
|
|
569
|
+
var label = tab.tabTitle;
|
|
570
|
+
return (0, _react2.jsx)(_tabs.Tab, {
|
|
571
|
+
key: label,
|
|
572
|
+
testId: "link-picker-tab"
|
|
573
|
+
}, label);
|
|
574
|
+
}))), screenReaderText && (0, _react2.jsx)(_announcer.default, {
|
|
506
575
|
ariaLive: "assertive",
|
|
507
576
|
text: screenReaderText,
|
|
508
577
|
ariaRelevant: "additions",
|
|
@@ -604,5 +673,6 @@ function limit(items) {
|
|
|
604
673
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
605
674
|
}
|
|
606
675
|
|
|
607
|
-
var
|
|
608
|
-
|
|
676
|
+
var _default = (0, _reactIntlNext.injectIntl)(LinkPicker);
|
|
677
|
+
|
|
678
|
+
exports.default = _default;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.searchIconStyles = exports.rootContainerStyles = exports.listTitleStyles = void 0;
|
|
8
|
+
exports.searchIconStyles = exports.rootContainerStylesForLoader = exports.rootContainerStyles = exports.listTitleStyles = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -19,13 +19,15 @@ var _theme = require("@atlaskit/theme");
|
|
|
19
19
|
|
|
20
20
|
var _constants = require("@atlaskit/theme/constants");
|
|
21
21
|
|
|
22
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
22
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
23
23
|
|
|
24
24
|
var LINK_PICKER_WIDTH_IN_PX = 342;
|
|
25
25
|
var LINK_PICKER_MIN_HEIGHT_IN_PX = 234;
|
|
26
26
|
var rootContainerStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: ", "px;\n padding: ", "px;\n box-sizing: border-box;\n line-height: initial;\n min-height: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX, (0, _constants.gridSize)() * 2, LINK_PICKER_MIN_HEIGHT_IN_PX);
|
|
27
27
|
exports.rootContainerStyles = rootContainerStyles;
|
|
28
|
-
var
|
|
28
|
+
var rootContainerStylesForLoader = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n display: flex;\n align-items: center;\n justify-content: center;\n"])), rootContainerStyles);
|
|
29
|
+
exports.rootContainerStylesForLoader = rootContainerStylesForLoader;
|
|
30
|
+
var searchIconStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: ", "px;\n color: ", ";\n cursor: default;\n"])), (0, _constants.gridSize)() / 2, (0, _tokens.token)('color.icon', _colors.N500));
|
|
29
31
|
exports.searchIconStyles = searchIconStyles;
|
|
30
|
-
var listTitleStyles = (0, _react.css)(
|
|
32
|
+
var listTitleStyles = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n text-transform: uppercase;\n margin-bottom: ", "px;\n"])), _theme.typography.h100(), (0, _constants.gridSize)() / 2);
|
|
31
33
|
exports.listTitleStyles = listTitleStyles;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.LoaderFallback = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("@emotion/react");
|
|
11
|
+
|
|
12
|
+
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
13
|
+
|
|
14
|
+
var _styled = require("../link-picker/styled");
|
|
15
|
+
|
|
16
|
+
/** @jsx jsx */
|
|
17
|
+
var LoaderFallback = (0, _react.jsx)("div", {
|
|
18
|
+
css: _styled.rootContainerStylesForLoader,
|
|
19
|
+
"data-testid": "link-picker-root-loader-boundary-ui"
|
|
20
|
+
}, (0, _react.jsx)(_spinner.default, {
|
|
21
|
+
testId: "link-picker.component-loading-indicator",
|
|
22
|
+
size: "medium"
|
|
23
|
+
}));
|
|
24
|
+
exports.LoaderFallback = LoaderFallback;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/ui/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { AnalyticsErrorBoundary } from '@atlaskit/analytics-next';
|
|
3
|
+
import { LazySuspense, lazyForPaint } from 'react-loosely-lazy';
|
|
3
4
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
4
5
|
import { ErrorBoundaryFallback } from './error-boundary-fallback';
|
|
5
|
-
import {
|
|
6
|
+
import { LoaderFallback } from './loader-fallback';
|
|
6
7
|
const COMPONENT_NAME = 'LinkPicker';
|
|
7
8
|
const ANALYTICS_CHANNEL = 'media';
|
|
8
9
|
const PACKAGE_DATA = {
|
|
@@ -10,8 +11,13 @@ const PACKAGE_DATA = {
|
|
|
10
11
|
packageVersion,
|
|
11
12
|
componentName: COMPONENT_NAME
|
|
12
13
|
};
|
|
14
|
+
const LazyLinkPicker = lazyForPaint(() => import(
|
|
15
|
+
/* webpackChunkName: "@atlaskit-internal_link-picker" */
|
|
16
|
+
'./link-picker'));
|
|
13
17
|
export const ComposedLinkPicker = /*#__PURE__*/memo(props => /*#__PURE__*/React.createElement(AnalyticsErrorBoundary, {
|
|
14
18
|
channel: ANALYTICS_CHANNEL,
|
|
15
19
|
data: PACKAGE_DATA,
|
|
16
20
|
ErrorComponent: ErrorBoundaryFallback
|
|
17
|
-
}, /*#__PURE__*/React.createElement(
|
|
21
|
+
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
22
|
+
fallback: LoaderFallback
|
|
23
|
+
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props))));
|
|
@@ -4,6 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
import { PureComponent } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
|
+
import Tabs, { Tab, TabList } from '@atlaskit/tabs';
|
|
7
8
|
import { messages } from './messages';
|
|
8
9
|
import PanelTextInput from './text-input';
|
|
9
10
|
import LinkSearchList from './link-search-list';
|
|
@@ -88,6 +89,16 @@ class LinkPicker extends PureComponent {
|
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
|
|
92
|
+
_defineProperty(this, "getTabs", () => {
|
|
93
|
+
if (this.props.plugins && this.props.plugins.length > 1) {
|
|
94
|
+
return this.props.plugins.filter(plugin => !!plugin.tabTitle).map(plugin => ({
|
|
95
|
+
tabTitle: plugin.tabTitle
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return [];
|
|
100
|
+
});
|
|
101
|
+
|
|
91
102
|
_defineProperty(this, "isUrlPopulatedWithSelectedItem", () => {
|
|
92
103
|
/**
|
|
93
104
|
* When we use ArrowKey to navigate through result items,
|
|
@@ -181,25 +192,24 @@ class LinkPicker extends PureComponent {
|
|
|
181
192
|
selectedIndex,
|
|
182
193
|
items
|
|
183
194
|
} = this.state;
|
|
195
|
+
const {
|
|
196
|
+
intl
|
|
197
|
+
} = this.props;
|
|
184
198
|
const selectedItem = items[selectedIndex];
|
|
185
199
|
|
|
186
200
|
if (this.isUrlPopulatedWithSelectedItem()) {
|
|
187
|
-
this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
188
|
-
}
|
|
189
|
-
const normalized = normalizeUrl(url);
|
|
201
|
+
return this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
202
|
+
}
|
|
190
203
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
intl
|
|
196
|
-
} = this.props;
|
|
197
|
-
const linkInvalid = intl.formatMessage(messages.linkInvalid);
|
|
198
|
-
this.setState({
|
|
199
|
-
invalidUrl: linkInvalid
|
|
200
|
-
});
|
|
201
|
-
}
|
|
204
|
+
const normalized = normalizeUrl(url);
|
|
205
|
+
|
|
206
|
+
if (normalized) {
|
|
207
|
+
return this.handleInsert(normalized, null, 'manual');
|
|
202
208
|
}
|
|
209
|
+
|
|
210
|
+
return this.setState({
|
|
211
|
+
invalidUrl: intl.formatMessage(messages.linkInvalid)
|
|
212
|
+
});
|
|
203
213
|
});
|
|
204
214
|
|
|
205
215
|
_defineProperty(this, "handleKeyDown", event => {
|
|
@@ -267,7 +277,8 @@ class LinkPicker extends PureComponent {
|
|
|
267
277
|
url: normalizeUrl(props.url) || '',
|
|
268
278
|
displayText: props.displayText || '',
|
|
269
279
|
items: [],
|
|
270
|
-
invalidUrl: null
|
|
280
|
+
invalidUrl: null,
|
|
281
|
+
activePlugin: 0
|
|
271
282
|
};
|
|
272
283
|
/* Cache functions */
|
|
273
284
|
|
|
@@ -294,7 +305,7 @@ class LinkPicker extends PureComponent {
|
|
|
294
305
|
return null;
|
|
295
306
|
}
|
|
296
307
|
|
|
297
|
-
return this.props.plugins[
|
|
308
|
+
return this.props.plugins[this.state.activePlugin];
|
|
298
309
|
}
|
|
299
310
|
/**
|
|
300
311
|
* Interface between link picker and plugins to update results
|
|
@@ -337,10 +348,10 @@ class LinkPicker extends PureComponent {
|
|
|
337
348
|
return;
|
|
338
349
|
}
|
|
339
350
|
|
|
340
|
-
this.setState({
|
|
351
|
+
this.setState(prev => ({
|
|
341
352
|
items: limit(value.data),
|
|
342
353
|
isLoading: !done
|
|
343
|
-
});
|
|
354
|
+
}));
|
|
344
355
|
|
|
345
356
|
if (done) {
|
|
346
357
|
return;
|
|
@@ -369,6 +380,7 @@ class LinkPicker extends PureComponent {
|
|
|
369
380
|
}
|
|
370
381
|
} = this.props;
|
|
371
382
|
const activePlugin = this.getActivePlugin();
|
|
383
|
+
const tabs = this.getTabs();
|
|
372
384
|
const linkPlaceHolder = formatMessage(activePlugin ? messages.placeholder : messages.linkPlaceholder);
|
|
373
385
|
const linkLabel = formatMessage(messages.linkLabel);
|
|
374
386
|
const linkTextLabel = formatMessage(messages.linkTextLabel);
|
|
@@ -391,7 +403,21 @@ class LinkPicker extends PureComponent {
|
|
|
391
403
|
return jsx("div", {
|
|
392
404
|
"data-testid": "link-picker",
|
|
393
405
|
css: rootContainerStyles
|
|
394
|
-
},
|
|
406
|
+
}, tabs.length > 0 && jsx(Tabs, {
|
|
407
|
+
id: "link-picker-tabs",
|
|
408
|
+
testId: "link-picker-tabs",
|
|
409
|
+
onChange: activePlugin => this.setState({
|
|
410
|
+
activePlugin
|
|
411
|
+
}, () => {
|
|
412
|
+
this.updateResults();
|
|
413
|
+
})
|
|
414
|
+
}, jsx(TabList, null, tabs.map(tab => {
|
|
415
|
+
const label = tab.tabTitle;
|
|
416
|
+
return jsx(Tab, {
|
|
417
|
+
key: label,
|
|
418
|
+
testId: "link-picker-tab"
|
|
419
|
+
}, label);
|
|
420
|
+
}))), screenReaderText && jsx(Announcer, {
|
|
395
421
|
ariaLive: "assertive",
|
|
396
422
|
text: screenReaderText,
|
|
397
423
|
ariaRelevant: "additions",
|
|
@@ -492,4 +518,4 @@ function limit(items) {
|
|
|
492
518
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
493
519
|
}
|
|
494
520
|
|
|
495
|
-
export
|
|
521
|
+
export default injectIntl(LinkPicker);
|
|
@@ -14,6 +14,12 @@ export const rootContainerStyles = css`
|
|
|
14
14
|
line-height: initial;
|
|
15
15
|
min-height: ${LINK_PICKER_MIN_HEIGHT_IN_PX}px;
|
|
16
16
|
`;
|
|
17
|
+
export const rootContainerStylesForLoader = css`
|
|
18
|
+
${rootContainerStyles}
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
`;
|
|
17
23
|
export const searchIconStyles = css`
|
|
18
24
|
margin-left: ${gridSize() / 2}px;
|
|
19
25
|
color: ${token('color.icon', N500)};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import Spinner from '@atlaskit/spinner';
|
|
4
|
+
import { rootContainerStylesForLoader } from '../link-picker/styled';
|
|
5
|
+
export const LoaderFallback = jsx("div", {
|
|
6
|
+
css: rootContainerStylesForLoader,
|
|
7
|
+
"data-testid": "link-picker-root-loader-boundary-ui"
|
|
8
|
+
}, jsx(Spinner, {
|
|
9
|
+
testId: "link-picker.component-loading-indicator",
|
|
10
|
+
size: "medium"
|
|
11
|
+
}));
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/ui/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { AnalyticsErrorBoundary } from '@atlaskit/analytics-next';
|
|
3
|
+
import { LazySuspense, lazyForPaint } from 'react-loosely-lazy';
|
|
3
4
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
4
5
|
import { ErrorBoundaryFallback } from './error-boundary-fallback';
|
|
5
|
-
import {
|
|
6
|
+
import { LoaderFallback } from './loader-fallback';
|
|
6
7
|
var COMPONENT_NAME = 'LinkPicker';
|
|
7
8
|
var ANALYTICS_CHANNEL = 'media';
|
|
8
9
|
var PACKAGE_DATA = {
|
|
@@ -10,10 +11,17 @@ var PACKAGE_DATA = {
|
|
|
10
11
|
packageVersion: packageVersion,
|
|
11
12
|
componentName: COMPONENT_NAME
|
|
12
13
|
};
|
|
14
|
+
var LazyLinkPicker = lazyForPaint(function () {
|
|
15
|
+
return import(
|
|
16
|
+
/* webpackChunkName: "@atlaskit-internal_link-picker" */
|
|
17
|
+
'./link-picker');
|
|
18
|
+
});
|
|
13
19
|
export var ComposedLinkPicker = /*#__PURE__*/memo(function (props) {
|
|
14
20
|
return /*#__PURE__*/React.createElement(AnalyticsErrorBoundary, {
|
|
15
21
|
channel: ANALYTICS_CHANNEL,
|
|
16
22
|
data: PACKAGE_DATA,
|
|
17
23
|
ErrorComponent: ErrorBoundaryFallback
|
|
18
|
-
}, /*#__PURE__*/React.createElement(
|
|
24
|
+
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
25
|
+
fallback: LoaderFallback
|
|
26
|
+
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props)));
|
|
19
27
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -21,6 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
21
22
|
import { PureComponent } from 'react';
|
|
22
23
|
import { jsx } from '@emotion/react';
|
|
23
24
|
import { injectIntl } from 'react-intl-next';
|
|
25
|
+
import Tabs, { Tab, TabList } from '@atlaskit/tabs';
|
|
24
26
|
import { messages } from './messages';
|
|
25
27
|
import PanelTextInput from './text-input';
|
|
26
28
|
import LinkSearchList from './link-search-list';
|
|
@@ -128,6 +130,20 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
128
130
|
}
|
|
129
131
|
});
|
|
130
132
|
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "getTabs", function () {
|
|
134
|
+
if (_this.props.plugins && _this.props.plugins.length > 1) {
|
|
135
|
+
return _this.props.plugins.filter(function (plugin) {
|
|
136
|
+
return !!plugin.tabTitle;
|
|
137
|
+
}).map(function (plugin) {
|
|
138
|
+
return {
|
|
139
|
+
tabTitle: plugin.tabTitle
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return [];
|
|
145
|
+
});
|
|
146
|
+
|
|
131
147
|
_defineProperty(_assertThisInitialized(_this), "isUrlPopulatedWithSelectedItem", function () {
|
|
132
148
|
/**
|
|
133
149
|
* When we use ArrowKey to navigate through result items,
|
|
@@ -216,24 +232,22 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
216
232
|
url = _this$state5.url,
|
|
217
233
|
selectedIndex = _this$state5.selectedIndex,
|
|
218
234
|
items = _this$state5.items;
|
|
235
|
+
var intl = _this.props.intl;
|
|
219
236
|
var selectedItem = items[selectedIndex];
|
|
220
237
|
|
|
221
238
|
if (_this.isUrlPopulatedWithSelectedItem()) {
|
|
222
|
-
_this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
223
|
-
} else if (url.length > 0) {
|
|
224
|
-
var normalized = normalizeUrl(url);
|
|
225
|
-
|
|
226
|
-
if (normalized) {
|
|
227
|
-
_this.handleInsert(normalized, null, 'manual');
|
|
228
|
-
} else {
|
|
229
|
-
var intl = _this.props.intl;
|
|
230
|
-
var linkInvalid = intl.formatMessage(messages.linkInvalid);
|
|
231
|
-
|
|
232
|
-
_this.setState({
|
|
233
|
-
invalidUrl: linkInvalid
|
|
234
|
-
});
|
|
235
|
-
}
|
|
239
|
+
return _this.handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
236
240
|
}
|
|
241
|
+
|
|
242
|
+
var normalized = normalizeUrl(url);
|
|
243
|
+
|
|
244
|
+
if (normalized) {
|
|
245
|
+
return _this.handleInsert(normalized, null, 'manual');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return _this.setState({
|
|
249
|
+
invalidUrl: intl.formatMessage(messages.linkInvalid)
|
|
250
|
+
});
|
|
237
251
|
});
|
|
238
252
|
|
|
239
253
|
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
|
|
@@ -296,7 +310,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
296
310
|
url: normalizeUrl(props.url) || '',
|
|
297
311
|
displayText: props.displayText || '',
|
|
298
312
|
items: [],
|
|
299
|
-
invalidUrl: null
|
|
313
|
+
invalidUrl: null,
|
|
314
|
+
activePlugin: 0
|
|
300
315
|
};
|
|
301
316
|
/* Cache functions */
|
|
302
317
|
|
|
@@ -326,7 +341,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
326
341
|
return null;
|
|
327
342
|
}
|
|
328
343
|
|
|
329
|
-
return this.props.plugins[
|
|
344
|
+
return this.props.plugins[this.state.activePlugin];
|
|
330
345
|
}
|
|
331
346
|
/**
|
|
332
347
|
* Interface between link picker and plugins to update results
|
|
@@ -336,21 +351,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
336
351
|
key: "updateResults",
|
|
337
352
|
value: function () {
|
|
338
353
|
var _updateResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
339
|
-
var
|
|
354
|
+
var _this2 = this;
|
|
340
355
|
|
|
341
|
-
|
|
356
|
+
var queryVersion, activePlugin, updates, _loop, _ret;
|
|
357
|
+
|
|
358
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
342
359
|
while (1) {
|
|
343
|
-
switch (
|
|
360
|
+
switch (_context3.prev = _context3.next) {
|
|
344
361
|
case 0:
|
|
345
362
|
queryVersion = ++this.queryVersion;
|
|
346
363
|
activePlugin = this.getActivePlugin();
|
|
347
364
|
|
|
348
365
|
if (activePlugin) {
|
|
349
|
-
|
|
366
|
+
_context3.next = 4;
|
|
350
367
|
break;
|
|
351
368
|
}
|
|
352
369
|
|
|
353
|
-
return
|
|
370
|
+
return _context3.abrupt("return");
|
|
354
371
|
|
|
355
372
|
case 4:
|
|
356
373
|
updates = activePlugin.resolve({
|
|
@@ -360,82 +377,114 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
360
377
|
isLoading: true,
|
|
361
378
|
items: []
|
|
362
379
|
});
|
|
363
|
-
|
|
380
|
+
_context3.prev = 6;
|
|
381
|
+
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
382
|
+
var done, value, _result$done, result;
|
|
383
|
+
|
|
384
|
+
return _regeneratorRuntime.wrap(function _loop$(_context2) {
|
|
385
|
+
while (1) {
|
|
386
|
+
switch (_context2.prev = _context2.next) {
|
|
387
|
+
case 0:
|
|
388
|
+
done = false;
|
|
389
|
+
value = void 0;
|
|
390
|
+
|
|
391
|
+
if (!(updates instanceof Promise)) {
|
|
392
|
+
_context2.next = 9;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
done = true;
|
|
397
|
+
_context2.next = 6;
|
|
398
|
+
return updates;
|
|
399
|
+
|
|
400
|
+
case 6:
|
|
401
|
+
value = _context2.sent;
|
|
402
|
+
_context2.next = 14;
|
|
403
|
+
break;
|
|
404
|
+
|
|
405
|
+
case 9:
|
|
406
|
+
_context2.next = 11;
|
|
407
|
+
return updates.next();
|
|
408
|
+
|
|
409
|
+
case 11:
|
|
410
|
+
result = _context2.sent;
|
|
411
|
+
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
412
|
+
value = result.value;
|
|
413
|
+
|
|
414
|
+
case 14:
|
|
415
|
+
if (!(queryVersion !== _this2.queryVersion)) {
|
|
416
|
+
_context2.next = 16;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return _context2.abrupt("return", {
|
|
421
|
+
v: void 0
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
case 16:
|
|
425
|
+
_this2.setState(function (prev) {
|
|
426
|
+
return {
|
|
427
|
+
items: limit(value.data),
|
|
428
|
+
isLoading: !done
|
|
429
|
+
};
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
if (!done) {
|
|
433
|
+
_context2.next = 19;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return _context2.abrupt("return", {
|
|
438
|
+
v: void 0
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
case 19:
|
|
442
|
+
case "end":
|
|
443
|
+
return _context2.stop();
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}, _loop);
|
|
447
|
+
});
|
|
364
448
|
|
|
365
|
-
case
|
|
449
|
+
case 8:
|
|
366
450
|
if (!(queryVersion === this.queryVersion)) {
|
|
367
|
-
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
done = false;
|
|
372
|
-
value = void 0;
|
|
373
|
-
|
|
374
|
-
if (!(updates instanceof Promise)) {
|
|
375
|
-
_context2.next = 17;
|
|
451
|
+
_context3.next = 15;
|
|
376
452
|
break;
|
|
377
453
|
}
|
|
378
454
|
|
|
379
|
-
|
|
380
|
-
_context2.next = 14;
|
|
381
|
-
return updates;
|
|
455
|
+
return _context3.delegateYield(_loop(), "t0", 10);
|
|
382
456
|
|
|
383
|
-
case
|
|
384
|
-
|
|
385
|
-
_context2.next = 22;
|
|
386
|
-
break;
|
|
387
|
-
|
|
388
|
-
case 17:
|
|
389
|
-
_context2.next = 19;
|
|
390
|
-
return updates.next();
|
|
457
|
+
case 10:
|
|
458
|
+
_ret = _context3.t0;
|
|
391
459
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
395
|
-
value = result.value;
|
|
396
|
-
|
|
397
|
-
case 22:
|
|
398
|
-
if (!(queryVersion !== this.queryVersion)) {
|
|
399
|
-
_context2.next = 24;
|
|
460
|
+
if (!(_typeof(_ret) === "object")) {
|
|
461
|
+
_context3.next = 13;
|
|
400
462
|
break;
|
|
401
463
|
}
|
|
402
464
|
|
|
403
|
-
return
|
|
404
|
-
|
|
405
|
-
case 24:
|
|
406
|
-
this.setState({
|
|
407
|
-
items: limit(value.data),
|
|
408
|
-
isLoading: !done
|
|
409
|
-
});
|
|
465
|
+
return _context3.abrupt("return", _ret.v);
|
|
410
466
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return _context2.abrupt("return");
|
|
417
|
-
|
|
418
|
-
case 27:
|
|
419
|
-
_context2.next = 7;
|
|
467
|
+
case 13:
|
|
468
|
+
_context3.next = 8;
|
|
420
469
|
break;
|
|
421
470
|
|
|
422
|
-
case
|
|
423
|
-
|
|
471
|
+
case 15:
|
|
472
|
+
_context3.next = 20;
|
|
424
473
|
break;
|
|
425
474
|
|
|
426
|
-
case
|
|
427
|
-
|
|
428
|
-
|
|
475
|
+
case 17:
|
|
476
|
+
_context3.prev = 17;
|
|
477
|
+
_context3.t1 = _context3["catch"](6);
|
|
429
478
|
this.setState({
|
|
430
479
|
isLoading: false
|
|
431
480
|
});
|
|
432
481
|
|
|
433
|
-
case
|
|
482
|
+
case 20:
|
|
434
483
|
case "end":
|
|
435
|
-
return
|
|
484
|
+
return _context3.stop();
|
|
436
485
|
}
|
|
437
486
|
}
|
|
438
|
-
}, _callee2, this, [[6,
|
|
487
|
+
}, _callee2, this, [[6, 17]]);
|
|
439
488
|
}));
|
|
440
489
|
|
|
441
490
|
function updateResults() {
|
|
@@ -447,6 +496,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
447
496
|
}, {
|
|
448
497
|
key: "render",
|
|
449
498
|
value: function render() {
|
|
499
|
+
var _this3 = this;
|
|
500
|
+
|
|
450
501
|
var _this$state7 = this.state,
|
|
451
502
|
items = _this$state7.items,
|
|
452
503
|
isLoading = _this$state7.isLoading,
|
|
@@ -457,6 +508,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
457
508
|
displayText = _this$state7.displayText;
|
|
458
509
|
var formatMessage = this.props.intl.formatMessage;
|
|
459
510
|
var activePlugin = this.getActivePlugin();
|
|
511
|
+
var tabs = this.getTabs();
|
|
460
512
|
var linkPlaceHolder = formatMessage(activePlugin ? messages.placeholder : messages.linkPlaceholder);
|
|
461
513
|
var linkLabel = formatMessage(messages.linkLabel);
|
|
462
514
|
var linkTextLabel = formatMessage(messages.linkTextLabel);
|
|
@@ -479,7 +531,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
479
531
|
return jsx("div", {
|
|
480
532
|
"data-testid": "link-picker",
|
|
481
533
|
css: rootContainerStyles
|
|
482
|
-
},
|
|
534
|
+
}, tabs.length > 0 && jsx(Tabs, {
|
|
535
|
+
id: "link-picker-tabs",
|
|
536
|
+
testId: "link-picker-tabs",
|
|
537
|
+
onChange: function onChange(activePlugin) {
|
|
538
|
+
return _this3.setState({
|
|
539
|
+
activePlugin: activePlugin
|
|
540
|
+
}, function () {
|
|
541
|
+
_this3.updateResults();
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}, jsx(TabList, null, tabs.map(function (tab) {
|
|
545
|
+
var label = tab.tabTitle;
|
|
546
|
+
return jsx(Tab, {
|
|
547
|
+
key: label,
|
|
548
|
+
testId: "link-picker-tab"
|
|
549
|
+
}, label);
|
|
550
|
+
}))), screenReaderText && jsx(Announcer, {
|
|
483
551
|
ariaLive: "assertive",
|
|
484
552
|
text: screenReaderText,
|
|
485
553
|
ariaRelevant: "additions",
|
|
@@ -582,4 +650,4 @@ function limit(items) {
|
|
|
582
650
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
583
651
|
}
|
|
584
652
|
|
|
585
|
-
export
|
|
653
|
+
export default injectIntl(LinkPicker);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
4
|
|
|
5
5
|
import { token } from '@atlaskit/tokens';
|
|
6
6
|
import { css } from '@emotion/react';
|
|
@@ -12,5 +12,6 @@ import { gridSize } from '@atlaskit/theme/constants';
|
|
|
12
12
|
var LINK_PICKER_WIDTH_IN_PX = 342;
|
|
13
13
|
var LINK_PICKER_MIN_HEIGHT_IN_PX = 234;
|
|
14
14
|
export var rootContainerStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n padding: ", "px;\n box-sizing: border-box;\n line-height: initial;\n min-height: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX, gridSize() * 2, LINK_PICKER_MIN_HEIGHT_IN_PX);
|
|
15
|
-
export var
|
|
16
|
-
export var
|
|
15
|
+
export var rootContainerStylesForLoader = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n display: flex;\n align-items: center;\n justify-content: center;\n"])), rootContainerStyles);
|
|
16
|
+
export var searchIconStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: ", "px;\n color: ", ";\n cursor: default;\n"])), gridSize() / 2, token('color.icon', N500));
|
|
17
|
+
export var listTitleStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n text-transform: uppercase;\n margin-bottom: ", "px;\n"])), typography.h100(), gridSize() / 2);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import Spinner from '@atlaskit/spinner';
|
|
4
|
+
import { rootContainerStylesForLoader } from '../link-picker/styled';
|
|
5
|
+
export var LoaderFallback = jsx("div", {
|
|
6
|
+
css: rootContainerStylesForLoader,
|
|
7
|
+
"data-testid": "link-picker-root-loader-boundary-ui"
|
|
8
|
+
}, jsx(Spinner, {
|
|
9
|
+
testId: "link-picker.component-loading-indicator",
|
|
10
|
+
size: "medium"
|
|
11
|
+
}));
|
package/dist/esm/version.json
CHANGED
|
@@ -44,8 +44,9 @@ export interface State {
|
|
|
44
44
|
isEditing: boolean;
|
|
45
45
|
displayText: string;
|
|
46
46
|
invalidUrl: string | null;
|
|
47
|
+
activePlugin: number;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<WrappedComponentProps<"intl"> & LinkPickerProps>> & {
|
|
49
50
|
WrappedComponent: import("react").ComponentType<WrappedComponentProps<"intl"> & LinkPickerProps>;
|
|
50
51
|
};
|
|
51
|
-
export
|
|
52
|
+
export default _default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const rootContainerStyles: import("@emotion/react").SerializedStyles;
|
|
2
|
+
export declare const rootContainerStylesForLoader: import("@emotion/react").SerializedStyles;
|
|
2
3
|
export declare const searchIconStyles: import("@emotion/react").SerializedStyles;
|
|
3
4
|
export declare const listTitleStyles: import("@emotion/react").SerializedStyles;
|
package/dist/types/ui/types.d.ts
CHANGED
|
@@ -36,5 +36,9 @@ export interface ResolveResult {
|
|
|
36
36
|
data: LinkSearchListItemData[];
|
|
37
37
|
}
|
|
38
38
|
export interface LinkPickerPlugin {
|
|
39
|
+
/** Uniquely identify the tab */
|
|
40
|
+
tabKey?: string;
|
|
41
|
+
/** Human-readable label for the plugin */
|
|
42
|
+
tabTitle?: string;
|
|
39
43
|
resolve: (state: LinkPickerState) => Promise<ResolveResult> | AsyncGenerator<ResolveResult, ResolveResult>;
|
|
40
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@atlaskit/form": "^8.5.1",
|
|
36
36
|
"@atlaskit/icon": "^21.10.0",
|
|
37
37
|
"@atlaskit/spinner": "^15.1.0",
|
|
38
|
+
"@atlaskit/tabs": "^13.2.11",
|
|
38
39
|
"@atlaskit/textfield": "^5.1.7",
|
|
39
40
|
"@atlaskit/theme": "^12.1.0",
|
|
40
41
|
"@atlaskit/tokens": "^0.10.0",
|
|
@@ -43,7 +44,8 @@
|
|
|
43
44
|
"@babel/runtime": "^7.0.0",
|
|
44
45
|
"@emotion/react": "^11.7.1",
|
|
45
46
|
"date-fns": "^2.17.0",
|
|
46
|
-
"linkify-it": "^2.0.3"
|
|
47
|
+
"linkify-it": "^2.0.3",
|
|
48
|
+
"react-loosely-lazy": "^0.5.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"react": "^16.8.0",
|
|
@@ -52,16 +54,19 @@
|
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@atlaskit/activity-provider": "^2.3.2",
|
|
54
56
|
"@atlaskit/docs": "*",
|
|
55
|
-
"@atlaskit/link-test-helpers": "^1.
|
|
57
|
+
"@atlaskit/link-test-helpers": "^1.3.0",
|
|
56
58
|
"@atlaskit/popup": "^1.3.5",
|
|
57
59
|
"@atlaskit/ssr": "*",
|
|
58
60
|
"@atlaskit/visual-regression": "*",
|
|
59
61
|
"@atlaskit/webdriver-runner": "*",
|
|
60
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
61
|
-
"@atlassian/link-picker-atlassian-plugin": "^
|
|
63
|
+
"@atlassian/link-picker-atlassian-plugin": "^14.0.0",
|
|
64
|
+
"@atlassian/link-picker-plugins": "^1.0.0",
|
|
62
65
|
"@atlassian/search-provider": "^2.3.0",
|
|
63
66
|
"@testing-library/dom": "^7.7.3",
|
|
67
|
+
"@testing-library/jest-dom": "^4.1.0",
|
|
64
68
|
"@testing-library/react": "^8.0.1",
|
|
69
|
+
"@testing-library/user-event": "10.4.0",
|
|
65
70
|
"enzyme": "^3.10.0",
|
|
66
71
|
"fetch-mock": "^8.0.0",
|
|
67
72
|
"mockdate": "^3.0.2",
|