@atlaskit/link-picker 1.2.1 → 1.4.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 +18 -0
- package/dist/cjs/ui/index.js +15 -4
- package/dist/cjs/ui/link-picker/index.js +139 -67
- 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 +33 -6
- 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 +133 -63
- 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.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`140453ba9f6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/140453ba9f6) - [ux] Move tabs to be below input fields
|
|
8
|
+
|
|
9
|
+
## 1.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`3b5e61f9b3b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3b5e61f9b3b) - [ux] Adds in TAB UI support for Link Picker
|
|
14
|
+
|
|
15
|
+
## 1.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`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
|
|
20
|
+
|
|
3
21
|
## 1.2.1
|
|
4
22
|
|
|
5
23
|
### Patch 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,
|
|
@@ -317,7 +334,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
317
334
|
url: (0, _url.normalizeUrl)(props.url) || '',
|
|
318
335
|
displayText: props.displayText || '',
|
|
319
336
|
items: [],
|
|
320
|
-
invalidUrl: null
|
|
337
|
+
invalidUrl: null,
|
|
338
|
+
activePlugin: 0
|
|
321
339
|
};
|
|
322
340
|
/* Cache functions */
|
|
323
341
|
|
|
@@ -347,7 +365,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
347
365
|
return null;
|
|
348
366
|
}
|
|
349
367
|
|
|
350
|
-
return this.props.plugins[
|
|
368
|
+
return this.props.plugins[this.state.activePlugin];
|
|
351
369
|
}
|
|
352
370
|
/**
|
|
353
371
|
* Interface between link picker and plugins to update results
|
|
@@ -357,21 +375,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
357
375
|
key: "updateResults",
|
|
358
376
|
value: function () {
|
|
359
377
|
var _updateResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
360
|
-
var
|
|
378
|
+
var _this2 = this;
|
|
379
|
+
|
|
380
|
+
var queryVersion, activePlugin, updates, _loop, _ret;
|
|
361
381
|
|
|
362
|
-
return _regenerator.default.wrap(function _callee2$(
|
|
382
|
+
return _regenerator.default.wrap(function _callee2$(_context3) {
|
|
363
383
|
while (1) {
|
|
364
|
-
switch (
|
|
384
|
+
switch (_context3.prev = _context3.next) {
|
|
365
385
|
case 0:
|
|
366
386
|
queryVersion = ++this.queryVersion;
|
|
367
387
|
activePlugin = this.getActivePlugin();
|
|
368
388
|
|
|
369
389
|
if (activePlugin) {
|
|
370
|
-
|
|
390
|
+
_context3.next = 4;
|
|
371
391
|
break;
|
|
372
392
|
}
|
|
373
393
|
|
|
374
|
-
return
|
|
394
|
+
return _context3.abrupt("return");
|
|
375
395
|
|
|
376
396
|
case 4:
|
|
377
397
|
updates = activePlugin.resolve({
|
|
@@ -381,82 +401,114 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
381
401
|
isLoading: true,
|
|
382
402
|
items: []
|
|
383
403
|
});
|
|
384
|
-
|
|
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
|
+
});
|
|
385
472
|
|
|
386
|
-
case
|
|
473
|
+
case 8:
|
|
387
474
|
if (!(queryVersion === this.queryVersion)) {
|
|
388
|
-
|
|
475
|
+
_context3.next = 15;
|
|
389
476
|
break;
|
|
390
477
|
}
|
|
391
478
|
|
|
392
|
-
|
|
393
|
-
value = void 0;
|
|
394
|
-
|
|
395
|
-
if (!(updates instanceof Promise)) {
|
|
396
|
-
_context2.next = 17;
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
479
|
+
return _context3.delegateYield(_loop(), "t0", 10);
|
|
399
480
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return updates;
|
|
481
|
+
case 10:
|
|
482
|
+
_ret = _context3.t0;
|
|
403
483
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
_context2.next = 22;
|
|
407
|
-
break;
|
|
408
|
-
|
|
409
|
-
case 17:
|
|
410
|
-
_context2.next = 19;
|
|
411
|
-
return updates.next();
|
|
412
|
-
|
|
413
|
-
case 19:
|
|
414
|
-
result = _context2.sent;
|
|
415
|
-
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
416
|
-
value = result.value;
|
|
417
|
-
|
|
418
|
-
case 22:
|
|
419
|
-
if (!(queryVersion !== this.queryVersion)) {
|
|
420
|
-
_context2.next = 24;
|
|
484
|
+
if (!((0, _typeof2.default)(_ret) === "object")) {
|
|
485
|
+
_context3.next = 13;
|
|
421
486
|
break;
|
|
422
487
|
}
|
|
423
488
|
|
|
424
|
-
return
|
|
489
|
+
return _context3.abrupt("return", _ret.v);
|
|
425
490
|
|
|
426
|
-
case
|
|
427
|
-
|
|
428
|
-
items: limit(value.data),
|
|
429
|
-
isLoading: !done
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
if (!done) {
|
|
433
|
-
_context2.next = 27;
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
return _context2.abrupt("return");
|
|
438
|
-
|
|
439
|
-
case 27:
|
|
440
|
-
_context2.next = 7;
|
|
491
|
+
case 13:
|
|
492
|
+
_context3.next = 8;
|
|
441
493
|
break;
|
|
442
494
|
|
|
443
|
-
case
|
|
444
|
-
|
|
495
|
+
case 15:
|
|
496
|
+
_context3.next = 20;
|
|
445
497
|
break;
|
|
446
498
|
|
|
447
|
-
case
|
|
448
|
-
|
|
449
|
-
|
|
499
|
+
case 17:
|
|
500
|
+
_context3.prev = 17;
|
|
501
|
+
_context3.t1 = _context3["catch"](6);
|
|
450
502
|
this.setState({
|
|
451
503
|
isLoading: false
|
|
452
504
|
});
|
|
453
505
|
|
|
454
|
-
case
|
|
506
|
+
case 20:
|
|
455
507
|
case "end":
|
|
456
|
-
return
|
|
508
|
+
return _context3.stop();
|
|
457
509
|
}
|
|
458
510
|
}
|
|
459
|
-
}, _callee2, this, [[6,
|
|
511
|
+
}, _callee2, this, [[6, 17]]);
|
|
460
512
|
}));
|
|
461
513
|
|
|
462
514
|
function updateResults() {
|
|
@@ -468,6 +520,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
468
520
|
}, {
|
|
469
521
|
key: "render",
|
|
470
522
|
value: function render() {
|
|
523
|
+
var _this3 = this;
|
|
524
|
+
|
|
471
525
|
var _this$state7 = this.state,
|
|
472
526
|
items = _this$state7.items,
|
|
473
527
|
isLoading = _this$state7.isLoading,
|
|
@@ -478,6 +532,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
478
532
|
displayText = _this$state7.displayText;
|
|
479
533
|
var formatMessage = this.props.intl.formatMessage;
|
|
480
534
|
var activePlugin = this.getActivePlugin();
|
|
535
|
+
var tabs = this.getTabs();
|
|
481
536
|
var linkPlaceHolder = formatMessage(activePlugin ? _messages.messages.placeholder : _messages.messages.linkPlaceholder);
|
|
482
537
|
var linkLabel = formatMessage(_messages.messages.linkLabel);
|
|
483
538
|
var linkTextLabel = formatMessage(_messages.messages.linkTextLabel);
|
|
@@ -542,7 +597,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
542
597
|
onChange: this.updateTextInput,
|
|
543
598
|
onClear: this.handleClearDisplayText,
|
|
544
599
|
clearLabel: formatMessage(_messages.messages.clearText)
|
|
545
|
-
}),
|
|
600
|
+
}), tabs.length > 0 && (0, _react2.jsx)(_tabs.default, {
|
|
601
|
+
id: "link-picker-tabs",
|
|
602
|
+
testId: "link-picker-tabs",
|
|
603
|
+
onChange: function onChange(activePlugin) {
|
|
604
|
+
return _this3.setState({
|
|
605
|
+
activePlugin: activePlugin
|
|
606
|
+
}, function () {
|
|
607
|
+
_this3.updateResults();
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
}, (0, _react2.jsx)(_tabs.TabList, null, tabs.map(function (tab) {
|
|
611
|
+
var label = tab.tabTitle;
|
|
612
|
+
return (0, _react2.jsx)(_tabs.Tab, {
|
|
613
|
+
key: label,
|
|
614
|
+
testId: "link-picker-tab"
|
|
615
|
+
}, label);
|
|
616
|
+
}))), !!items.length && (0, _react2.jsx)("div", {
|
|
546
617
|
css: _styled.listTitleStyles,
|
|
547
618
|
id: "link-picker-list-title",
|
|
548
619
|
"data-testid": "link-picker-list-title"
|
|
@@ -602,5 +673,6 @@ function limit(items) {
|
|
|
602
673
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
603
674
|
}
|
|
604
675
|
|
|
605
|
-
var
|
|
606
|
-
|
|
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,
|
|
@@ -266,7 +277,8 @@ class LinkPicker extends PureComponent {
|
|
|
266
277
|
url: normalizeUrl(props.url) || '',
|
|
267
278
|
displayText: props.displayText || '',
|
|
268
279
|
items: [],
|
|
269
|
-
invalidUrl: null
|
|
280
|
+
invalidUrl: null,
|
|
281
|
+
activePlugin: 0
|
|
270
282
|
};
|
|
271
283
|
/* Cache functions */
|
|
272
284
|
|
|
@@ -293,7 +305,7 @@ class LinkPicker extends PureComponent {
|
|
|
293
305
|
return null;
|
|
294
306
|
}
|
|
295
307
|
|
|
296
|
-
return this.props.plugins[
|
|
308
|
+
return this.props.plugins[this.state.activePlugin];
|
|
297
309
|
}
|
|
298
310
|
/**
|
|
299
311
|
* Interface between link picker and plugins to update results
|
|
@@ -336,10 +348,10 @@ class LinkPicker extends PureComponent {
|
|
|
336
348
|
return;
|
|
337
349
|
}
|
|
338
350
|
|
|
339
|
-
this.setState({
|
|
351
|
+
this.setState(prev => ({
|
|
340
352
|
items: limit(value.data),
|
|
341
353
|
isLoading: !done
|
|
342
|
-
});
|
|
354
|
+
}));
|
|
343
355
|
|
|
344
356
|
if (done) {
|
|
345
357
|
return;
|
|
@@ -368,6 +380,7 @@ class LinkPicker extends PureComponent {
|
|
|
368
380
|
}
|
|
369
381
|
} = this.props;
|
|
370
382
|
const activePlugin = this.getActivePlugin();
|
|
383
|
+
const tabs = this.getTabs();
|
|
371
384
|
const linkPlaceHolder = formatMessage(activePlugin ? messages.placeholder : messages.linkPlaceholder);
|
|
372
385
|
const linkLabel = formatMessage(messages.linkLabel);
|
|
373
386
|
const linkTextLabel = formatMessage(messages.linkTextLabel);
|
|
@@ -432,7 +445,21 @@ class LinkPicker extends PureComponent {
|
|
|
432
445
|
onChange: this.updateTextInput,
|
|
433
446
|
onClear: this.handleClearDisplayText,
|
|
434
447
|
clearLabel: formatMessage(messages.clearText)
|
|
435
|
-
}),
|
|
448
|
+
}), tabs.length > 0 && jsx(Tabs, {
|
|
449
|
+
id: "link-picker-tabs",
|
|
450
|
+
testId: "link-picker-tabs",
|
|
451
|
+
onChange: activePlugin => this.setState({
|
|
452
|
+
activePlugin
|
|
453
|
+
}, () => {
|
|
454
|
+
this.updateResults();
|
|
455
|
+
})
|
|
456
|
+
}, jsx(TabList, null, tabs.map(tab => {
|
|
457
|
+
const label = tab.tabTitle;
|
|
458
|
+
return jsx(Tab, {
|
|
459
|
+
key: label,
|
|
460
|
+
testId: "link-picker-tab"
|
|
461
|
+
}, label);
|
|
462
|
+
}))), !!items.length && jsx("div", {
|
|
436
463
|
css: listTitleStyles,
|
|
437
464
|
id: "link-picker-list-title",
|
|
438
465
|
"data-testid": "link-picker-list-title"
|
|
@@ -491,4 +518,4 @@ function limit(items) {
|
|
|
491
518
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
492
519
|
}
|
|
493
520
|
|
|
494
|
-
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,
|
|
@@ -294,7 +310,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
294
310
|
url: normalizeUrl(props.url) || '',
|
|
295
311
|
displayText: props.displayText || '',
|
|
296
312
|
items: [],
|
|
297
|
-
invalidUrl: null
|
|
313
|
+
invalidUrl: null,
|
|
314
|
+
activePlugin: 0
|
|
298
315
|
};
|
|
299
316
|
/* Cache functions */
|
|
300
317
|
|
|
@@ -324,7 +341,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
324
341
|
return null;
|
|
325
342
|
}
|
|
326
343
|
|
|
327
|
-
return this.props.plugins[
|
|
344
|
+
return this.props.plugins[this.state.activePlugin];
|
|
328
345
|
}
|
|
329
346
|
/**
|
|
330
347
|
* Interface between link picker and plugins to update results
|
|
@@ -334,21 +351,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
334
351
|
key: "updateResults",
|
|
335
352
|
value: function () {
|
|
336
353
|
var _updateResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
337
|
-
var
|
|
354
|
+
var _this2 = this;
|
|
355
|
+
|
|
356
|
+
var queryVersion, activePlugin, updates, _loop, _ret;
|
|
338
357
|
|
|
339
|
-
return _regeneratorRuntime.wrap(function _callee2$(
|
|
358
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
340
359
|
while (1) {
|
|
341
|
-
switch (
|
|
360
|
+
switch (_context3.prev = _context3.next) {
|
|
342
361
|
case 0:
|
|
343
362
|
queryVersion = ++this.queryVersion;
|
|
344
363
|
activePlugin = this.getActivePlugin();
|
|
345
364
|
|
|
346
365
|
if (activePlugin) {
|
|
347
|
-
|
|
366
|
+
_context3.next = 4;
|
|
348
367
|
break;
|
|
349
368
|
}
|
|
350
369
|
|
|
351
|
-
return
|
|
370
|
+
return _context3.abrupt("return");
|
|
352
371
|
|
|
353
372
|
case 4:
|
|
354
373
|
updates = activePlugin.resolve({
|
|
@@ -358,82 +377,114 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
358
377
|
isLoading: true,
|
|
359
378
|
items: []
|
|
360
379
|
});
|
|
361
|
-
|
|
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
|
+
});
|
|
362
448
|
|
|
363
|
-
case
|
|
449
|
+
case 8:
|
|
364
450
|
if (!(queryVersion === this.queryVersion)) {
|
|
365
|
-
|
|
451
|
+
_context3.next = 15;
|
|
366
452
|
break;
|
|
367
453
|
}
|
|
368
454
|
|
|
369
|
-
|
|
370
|
-
value = void 0;
|
|
455
|
+
return _context3.delegateYield(_loop(), "t0", 10);
|
|
371
456
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
done = true;
|
|
378
|
-
_context2.next = 14;
|
|
379
|
-
return updates;
|
|
457
|
+
case 10:
|
|
458
|
+
_ret = _context3.t0;
|
|
380
459
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
_context2.next = 22;
|
|
384
|
-
break;
|
|
385
|
-
|
|
386
|
-
case 17:
|
|
387
|
-
_context2.next = 19;
|
|
388
|
-
return updates.next();
|
|
389
|
-
|
|
390
|
-
case 19:
|
|
391
|
-
result = _context2.sent;
|
|
392
|
-
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
393
|
-
value = result.value;
|
|
394
|
-
|
|
395
|
-
case 22:
|
|
396
|
-
if (!(queryVersion !== this.queryVersion)) {
|
|
397
|
-
_context2.next = 24;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return _context2.abrupt("return");
|
|
402
|
-
|
|
403
|
-
case 24:
|
|
404
|
-
this.setState({
|
|
405
|
-
items: limit(value.data),
|
|
406
|
-
isLoading: !done
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
if (!done) {
|
|
410
|
-
_context2.next = 27;
|
|
460
|
+
if (!(_typeof(_ret) === "object")) {
|
|
461
|
+
_context3.next = 13;
|
|
411
462
|
break;
|
|
412
463
|
}
|
|
413
464
|
|
|
414
|
-
return
|
|
465
|
+
return _context3.abrupt("return", _ret.v);
|
|
415
466
|
|
|
416
|
-
case
|
|
417
|
-
|
|
467
|
+
case 13:
|
|
468
|
+
_context3.next = 8;
|
|
418
469
|
break;
|
|
419
470
|
|
|
420
|
-
case
|
|
421
|
-
|
|
471
|
+
case 15:
|
|
472
|
+
_context3.next = 20;
|
|
422
473
|
break;
|
|
423
474
|
|
|
424
|
-
case
|
|
425
|
-
|
|
426
|
-
|
|
475
|
+
case 17:
|
|
476
|
+
_context3.prev = 17;
|
|
477
|
+
_context3.t1 = _context3["catch"](6);
|
|
427
478
|
this.setState({
|
|
428
479
|
isLoading: false
|
|
429
480
|
});
|
|
430
481
|
|
|
431
|
-
case
|
|
482
|
+
case 20:
|
|
432
483
|
case "end":
|
|
433
|
-
return
|
|
484
|
+
return _context3.stop();
|
|
434
485
|
}
|
|
435
486
|
}
|
|
436
|
-
}, _callee2, this, [[6,
|
|
487
|
+
}, _callee2, this, [[6, 17]]);
|
|
437
488
|
}));
|
|
438
489
|
|
|
439
490
|
function updateResults() {
|
|
@@ -445,6 +496,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
445
496
|
}, {
|
|
446
497
|
key: "render",
|
|
447
498
|
value: function render() {
|
|
499
|
+
var _this3 = this;
|
|
500
|
+
|
|
448
501
|
var _this$state7 = this.state,
|
|
449
502
|
items = _this$state7.items,
|
|
450
503
|
isLoading = _this$state7.isLoading,
|
|
@@ -455,6 +508,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
455
508
|
displayText = _this$state7.displayText;
|
|
456
509
|
var formatMessage = this.props.intl.formatMessage;
|
|
457
510
|
var activePlugin = this.getActivePlugin();
|
|
511
|
+
var tabs = this.getTabs();
|
|
458
512
|
var linkPlaceHolder = formatMessage(activePlugin ? messages.placeholder : messages.linkPlaceholder);
|
|
459
513
|
var linkLabel = formatMessage(messages.linkLabel);
|
|
460
514
|
var linkTextLabel = formatMessage(messages.linkTextLabel);
|
|
@@ -519,7 +573,23 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
519
573
|
onChange: this.updateTextInput,
|
|
520
574
|
onClear: this.handleClearDisplayText,
|
|
521
575
|
clearLabel: formatMessage(messages.clearText)
|
|
522
|
-
}),
|
|
576
|
+
}), tabs.length > 0 && jsx(Tabs, {
|
|
577
|
+
id: "link-picker-tabs",
|
|
578
|
+
testId: "link-picker-tabs",
|
|
579
|
+
onChange: function onChange(activePlugin) {
|
|
580
|
+
return _this3.setState({
|
|
581
|
+
activePlugin: activePlugin
|
|
582
|
+
}, function () {
|
|
583
|
+
_this3.updateResults();
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
}, jsx(TabList, null, tabs.map(function (tab) {
|
|
587
|
+
var label = tab.tabTitle;
|
|
588
|
+
return jsx(Tab, {
|
|
589
|
+
key: label,
|
|
590
|
+
testId: "link-picker-tab"
|
|
591
|
+
}, label);
|
|
592
|
+
}))), !!items.length && jsx("div", {
|
|
523
593
|
css: listTitleStyles,
|
|
524
594
|
id: "link-picker-list-title",
|
|
525
595
|
"data-testid": "link-picker-list-title"
|
|
@@ -580,4 +650,4 @@ function limit(items) {
|
|
|
580
650
|
return items.slice(0, RECENT_SEARCH_LIST_SIZE);
|
|
581
651
|
}
|
|
582
652
|
|
|
583
|
-
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.1",
|
|
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",
|