@atlaskit/link-picker 1.9.3 → 1.10.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 +12 -0
- package/dist/cjs/analytics.codegen.js +1 -1
- package/dist/cjs/common/analytics/context.js +1 -0
- package/dist/cjs/services/use-plugins/index.js +1 -0
- package/dist/cjs/ui/error-boundary/index.js +104 -0
- package/dist/cjs/ui/index.js +8 -5
- package/dist/cjs/ui/link-picker/index.js +21 -8
- package/dist/cjs/ui/link-picker/utils.js +14 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics.codegen.js +1 -1
- package/dist/es2019/common/analytics/context.js +1 -0
- package/dist/es2019/services/use-plugins/index.js +1 -0
- package/dist/es2019/ui/error-boundary/index.js +62 -0
- package/dist/es2019/ui/index.js +6 -4
- package/dist/es2019/ui/link-picker/index.js +20 -8
- package/dist/es2019/ui/link-picker/utils.js +9 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics.codegen.js +1 -1
- package/dist/esm/common/analytics/context.js +1 -0
- package/dist/esm/services/use-plugins/index.js +1 -0
- package/dist/esm/ui/error-boundary/index.js +81 -0
- package/dist/esm/ui/index.js +6 -4
- package/dist/esm/ui/link-picker/index.js +20 -8
- package/dist/esm/ui/link-picker/utils.js +9 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics.codegen.d.ts +14 -1
- package/dist/types/services/use-plugins/index.d.ts +1 -0
- package/dist/types/ui/error-boundary/index.d.ts +27 -0
- package/dist/types/ui/index.d.ts +2 -6
- package/dist/types/ui/link-picker/utils.d.ts +5 -0
- package/dist/types/ui/types.d.ts +10 -0
- package/package.json +4 -4
- package/report.api.md +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/link-picker
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`7dbc77d866a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7dbc77d866a) - Adds support for plugins providing metadata about resolved links.
|
|
8
|
+
|
|
9
|
+
## 1.9.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`81ac9ce10ff`](https://bitbucket.org/atlassian/atlassian-frontend/commits/81ac9ce10ff) - Update error boundary implementation to replace analytic instrumentation for uncaught errors.
|
|
14
|
+
|
|
3
15
|
## 1.9.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ exports.default = void 0;
|
|
|
10
10
|
*
|
|
11
11
|
* Generates analytics utilities from the package analytics spec yaml
|
|
12
12
|
*
|
|
13
|
-
* @codegen <<SignedSource::
|
|
13
|
+
* @codegen <<SignedSource::e8a730530bb93e19d0b85114da0581c8>>
|
|
14
14
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
15
15
|
*/
|
|
16
16
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = exports.BaseErrorBoundary = void 0;
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
29
|
+
|
|
30
|
+
var _analytics = _interopRequireDefault(require("../../analytics.codegen"));
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
41
|
+
var BaseErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
42
|
+
(0, _inherits2.default)(BaseErrorBoundary, _Component);
|
|
43
|
+
|
|
44
|
+
var _super = _createSuper(BaseErrorBoundary);
|
|
45
|
+
|
|
46
|
+
function BaseErrorBoundary(props) {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
(0, _classCallCheck2.default)(this, BaseErrorBoundary);
|
|
50
|
+
_this = _super.call(this, props);
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireAnalytics", function (analyticsErrorPayload) {
|
|
52
|
+
var _window, _window$navigator, _analyticsErrorPayloa, _analyticsErrorPayloa2;
|
|
53
|
+
|
|
54
|
+
var _this$props = _this.props,
|
|
55
|
+
createAnalyticsEvent = _this$props.createAnalyticsEvent,
|
|
56
|
+
channel = _this$props.channel;
|
|
57
|
+
createAnalyticsEvent((0, _analytics.default)('ui.linkPicker.unhandledErrorCaught', {
|
|
58
|
+
browserInfo: ((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent) || 'unknown',
|
|
59
|
+
error: analyticsErrorPayload.error.toString(),
|
|
60
|
+
componentStack: (_analyticsErrorPayloa = (_analyticsErrorPayloa2 = analyticsErrorPayload.info) === null || _analyticsErrorPayloa2 === void 0 ? void 0 : _analyticsErrorPayloa2.componentStack) !== null && _analyticsErrorPayloa !== void 0 ? _analyticsErrorPayloa : ''
|
|
61
|
+
})).fire(channel);
|
|
62
|
+
});
|
|
63
|
+
_this.state = {
|
|
64
|
+
hasError: false
|
|
65
|
+
};
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
(0, _createClass2.default)(BaseErrorBoundary, [{
|
|
70
|
+
key: "componentDidCatch",
|
|
71
|
+
value: function componentDidCatch(error, info) {
|
|
72
|
+
var onError = this.props.onError;
|
|
73
|
+
var payload = {
|
|
74
|
+
error: error,
|
|
75
|
+
info: info
|
|
76
|
+
};
|
|
77
|
+
this.fireAnalytics(payload);
|
|
78
|
+
onError && onError(error, info);
|
|
79
|
+
this.setState({
|
|
80
|
+
hasError: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "render",
|
|
85
|
+
value: function render() {
|
|
86
|
+
var _this$props2 = this.props,
|
|
87
|
+
children = _this$props2.children,
|
|
88
|
+
ErrorComponent = _this$props2.ErrorComponent;
|
|
89
|
+
var hasError = this.state.hasError;
|
|
90
|
+
|
|
91
|
+
if (hasError && ErrorComponent) {
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(ErrorComponent, null);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return children;
|
|
96
|
+
}
|
|
97
|
+
}]);
|
|
98
|
+
return BaseErrorBoundary;
|
|
99
|
+
}(_react.Component);
|
|
100
|
+
|
|
101
|
+
exports.BaseErrorBoundary = BaseErrorBoundary;
|
|
102
|
+
var ErrorBoundary = (0, _analyticsNext.withAnalyticsEvents)()(BaseErrorBoundary);
|
|
103
|
+
var _default = ErrorBoundary;
|
|
104
|
+
exports.default = _default;
|
package/dist/cjs/ui/index.js
CHANGED
|
@@ -11,14 +11,16 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
15
|
-
|
|
16
14
|
var _reactLooselyLazy = require("react-loosely-lazy");
|
|
17
15
|
|
|
16
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
17
|
+
|
|
18
18
|
var _constants = require("../common/constants");
|
|
19
19
|
|
|
20
20
|
var _version = require("../version.json");
|
|
21
21
|
|
|
22
|
+
var _errorBoundary = _interopRequireDefault(require("./error-boundary"));
|
|
23
|
+
|
|
22
24
|
var _errorBoundaryFallback = require("./error-boundary-fallback");
|
|
23
25
|
|
|
24
26
|
var _loaderFallback = require("./loader-fallback");
|
|
@@ -40,12 +42,13 @@ var LazyLinkPicker = (0, _reactLooselyLazy.lazyForPaint)(function () {
|
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
var ComposedLinkPicker = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
43
|
-
return /*#__PURE__*/_react.default.createElement(_analyticsNext.
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
|
|
46
|
+
data: PACKAGE_DATA
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement(_errorBoundary.default, {
|
|
44
48
|
channel: _constants.ANALYTICS_CHANNEL,
|
|
45
|
-
data: PACKAGE_DATA,
|
|
46
49
|
ErrorComponent: _errorBoundaryFallback.ErrorBoundaryFallback
|
|
47
50
|
}, /*#__PURE__*/_react.default.createElement(_reactLooselyLazy.LazySuspense, {
|
|
48
51
|
fallback: _loaderFallback.LoaderFallback
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement(LazyLinkPicker, props)));
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement(LazyLinkPicker, props))));
|
|
50
53
|
});
|
|
51
54
|
exports.ComposedLinkPicker = ComposedLinkPicker;
|
|
@@ -61,6 +61,8 @@ var _linkSearchError = _interopRequireWildcard(require("./link-search-error"));
|
|
|
61
61
|
|
|
62
62
|
var _formFooter = _interopRequireWildcard(require("./form-footer"));
|
|
63
63
|
|
|
64
|
+
var _utils = require("./utils");
|
|
65
|
+
|
|
64
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); }
|
|
65
67
|
|
|
66
68
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
@@ -160,6 +162,7 @@ function LinkPicker(_ref) {
|
|
|
160
162
|
items = _usePlugins.items,
|
|
161
163
|
isLoading = _usePlugins.isLoading,
|
|
162
164
|
isActivePlugin = _usePlugins.isActivePlugin,
|
|
165
|
+
activePlugin = _usePlugins.activePlugin,
|
|
163
166
|
tabs = _usePlugins.tabs,
|
|
164
167
|
error = _usePlugins.error,
|
|
165
168
|
retry = _usePlugins.retry,
|
|
@@ -190,10 +193,12 @@ function LinkPicker(_ref) {
|
|
|
190
193
|
}
|
|
191
194
|
}, [onContentResize, items, isLoading, isActivePlugin, tabs]);
|
|
192
195
|
var handleChangeUrl = (0, _react.useCallback)(function (e) {
|
|
196
|
+
/** Any on change event is triggered by manual input or paste, so source is null */
|
|
197
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
193
198
|
dispatch({
|
|
194
199
|
url: e.currentTarget.value
|
|
195
200
|
});
|
|
196
|
-
}, []);
|
|
201
|
+
}, [trackAttribute]);
|
|
197
202
|
var handleChangeText = (0, _react.useCallback)(function (e) {
|
|
198
203
|
dispatch({
|
|
199
204
|
displayText: e.currentTarget.value
|
|
@@ -224,23 +229,30 @@ function LinkPicker(_ref) {
|
|
|
224
229
|
break;
|
|
225
230
|
}
|
|
226
231
|
|
|
227
|
-
|
|
232
|
+
var item = items[updatedIndex];
|
|
233
|
+
|
|
234
|
+
if ([KEY_CODE_ARROW_DOWN, KEY_CODE_ARROW_UP].includes(keyCode) && item) {
|
|
228
235
|
/**
|
|
229
236
|
* Manually track that the url has been updated using searchResult method
|
|
230
237
|
*/
|
|
231
|
-
trackAttribute('linkFieldContent', getLinkFieldContent(
|
|
238
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(item.url));
|
|
232
239
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
240
|
+
trackAttribute('linkFieldContentInputSource', (0, _utils.getDataSource)(item, activePlugin));
|
|
233
241
|
dispatch({
|
|
234
242
|
activeIndex: updatedIndex,
|
|
235
243
|
selectedIndex: updatedIndex,
|
|
236
|
-
url:
|
|
244
|
+
url: item.url,
|
|
237
245
|
invalidUrl: false
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
|
-
}, [activeIndex, items, trackAttribute]);
|
|
248
|
+
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
241
249
|
var handleClear = (0, _react.useCallback)(function (field) {
|
|
242
250
|
dispatch((0, _defineProperty2.default)({}, field, ''));
|
|
243
251
|
}, []);
|
|
252
|
+
var handleUrlClear = (0, _react.useCallback)(function () {
|
|
253
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
254
|
+
handleClear('url');
|
|
255
|
+
}, [trackAttribute, handleClear]);
|
|
244
256
|
var handleMouseEnterResultItem = (0, _react.useCallback)(function (objectId) {
|
|
245
257
|
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
246
258
|
return item.objectId === objectId;
|
|
@@ -291,16 +303,17 @@ function LinkPicker(_ref) {
|
|
|
291
303
|
if (selectedItem) {
|
|
292
304
|
var _url = selectedItem.url,
|
|
293
305
|
name = selectedItem.name;
|
|
294
|
-
dispatchEvent(new Event('submit'));
|
|
295
306
|
/**
|
|
296
307
|
* Manually track that the url has been updated using searchResult method
|
|
297
308
|
*/
|
|
298
309
|
|
|
310
|
+
dispatchEvent(new Event('submit'));
|
|
299
311
|
trackAttribute('linkFieldContent', getLinkFieldContent(_url));
|
|
300
312
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
313
|
+
trackAttribute('linkFieldContentInputSource', (0, _utils.getDataSource)(selectedItem, activePlugin));
|
|
301
314
|
handleInsert(_url, name, 'typeAhead');
|
|
302
315
|
}
|
|
303
|
-
}, [handleInsert, trackAttribute, items]);
|
|
316
|
+
}, [handleInsert, trackAttribute, items, activePlugin]);
|
|
304
317
|
var handleSubmit = (0, _react.useCallback)(function (event) {
|
|
305
318
|
event.preventDefault();
|
|
306
319
|
|
|
@@ -361,7 +374,7 @@ function LinkPicker(_ref) {
|
|
|
361
374
|
"aria-activedescendant": ariaActiveDescendant,
|
|
362
375
|
"aria-describedby": screenReaderDescriptionId,
|
|
363
376
|
error: invalidUrl ? intl.formatMessage(_messages.messages.linkInvalid) : null,
|
|
364
|
-
onClear:
|
|
377
|
+
onClear: handleUrlClear,
|
|
365
378
|
onKeyDown: handleKeyDown,
|
|
366
379
|
onChange: handleChangeUrl
|
|
367
380
|
}), (0, _react2.jsx)(DisplayTextInputField, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isUndoEvent = exports.isRedoEvent = void 0;
|
|
6
|
+
exports.isUndoEvent = exports.isRedoEvent = exports.getDataSource = void 0;
|
|
7
7
|
|
|
8
8
|
var _browser = require("./browser");
|
|
9
9
|
|
|
@@ -23,5 +23,17 @@ var isRedoEvent = function isRedoEvent(e) {
|
|
|
23
23
|
!_browser.browser.mac && e.ctrlKey && e.keyCode === KeyYCode || _browser.browser.mac && e.metaKey && e.shiftKey && e.keyCode === KeyZCode || e.ctrlKey && e.shiftKey && e.keyCode === KeyZCode
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve the data source for a link given the item and the plugin that resolved it
|
|
28
|
+
*/
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
|
|
31
|
+
exports.isRedoEvent = isRedoEvent;
|
|
32
|
+
|
|
33
|
+
var getDataSource = function getDataSource(item, plugin) {
|
|
34
|
+
var _ref, _item$meta$source, _item$meta, _plugin$meta;
|
|
35
|
+
|
|
36
|
+
return (_ref = (_item$meta$source = (_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.source) !== null && _item$meta$source !== void 0 ? _item$meta$source : plugin === null || plugin === void 0 ? void 0 : (_plugin$meta = plugin.meta) === null || _plugin$meta === void 0 ? void 0 : _plugin$meta.source) !== null && _ref !== void 0 ? _ref : 'unknown';
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.getDataSource = getDataSource;
|
package/dist/cjs/version.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::e8a730530bb93e19d0b85114da0581c8>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
+
import createEventPayload from '../../analytics.codegen';
|
|
5
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
6
|
+
export class BaseErrorBoundary extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "fireAnalytics", analyticsErrorPayload => {
|
|
11
|
+
var _window, _window$navigator, _analyticsErrorPayloa, _analyticsErrorPayloa2;
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
createAnalyticsEvent,
|
|
15
|
+
channel
|
|
16
|
+
} = this.props;
|
|
17
|
+
createAnalyticsEvent(createEventPayload('ui.linkPicker.unhandledErrorCaught', {
|
|
18
|
+
browserInfo: ((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent) || 'unknown',
|
|
19
|
+
error: analyticsErrorPayload.error.toString(),
|
|
20
|
+
componentStack: (_analyticsErrorPayloa = (_analyticsErrorPayloa2 = analyticsErrorPayload.info) === null || _analyticsErrorPayloa2 === void 0 ? void 0 : _analyticsErrorPayloa2.componentStack) !== null && _analyticsErrorPayloa !== void 0 ? _analyticsErrorPayloa : ''
|
|
21
|
+
})).fire(channel);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.state = {
|
|
25
|
+
hasError: false
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
componentDidCatch(error, info) {
|
|
30
|
+
const {
|
|
31
|
+
onError
|
|
32
|
+
} = this.props;
|
|
33
|
+
const payload = {
|
|
34
|
+
error,
|
|
35
|
+
info
|
|
36
|
+
};
|
|
37
|
+
this.fireAnalytics(payload);
|
|
38
|
+
onError && onError(error, info);
|
|
39
|
+
this.setState({
|
|
40
|
+
hasError: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
const {
|
|
46
|
+
children,
|
|
47
|
+
ErrorComponent
|
|
48
|
+
} = this.props;
|
|
49
|
+
const {
|
|
50
|
+
hasError
|
|
51
|
+
} = this.state;
|
|
52
|
+
|
|
53
|
+
if (hasError && ErrorComponent) {
|
|
54
|
+
return /*#__PURE__*/React.createElement(ErrorComponent, null);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return children;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
const ErrorBoundary = withAnalyticsEvents()(BaseErrorBoundary);
|
|
62
|
+
export default ErrorBoundary;
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
|
-
import { AnalyticsErrorBoundary } from '@atlaskit/analytics-next';
|
|
3
2
|
import { LazySuspense, lazyForPaint } from 'react-loosely-lazy';
|
|
3
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
4
4
|
import { COMPONENT_NAME, ANALYTICS_CHANNEL } from '../common/constants';
|
|
5
5
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
6
|
+
import ErrorBoundary from './error-boundary';
|
|
6
7
|
import { ErrorBoundaryFallback } from './error-boundary-fallback';
|
|
7
8
|
import { LoaderFallback } from './loader-fallback';
|
|
8
9
|
export const PACKAGE_DATA = {
|
|
@@ -14,10 +15,11 @@ export const PACKAGE_DATA = {
|
|
|
14
15
|
const LazyLinkPicker = lazyForPaint(() => import(
|
|
15
16
|
/* webpackChunkName: "@atlaskit-internal_link-picker" */
|
|
16
17
|
'./link-picker'));
|
|
17
|
-
export const ComposedLinkPicker = /*#__PURE__*/memo(props => /*#__PURE__*/React.createElement(
|
|
18
|
+
export const ComposedLinkPicker = /*#__PURE__*/memo(props => /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
19
|
+
data: PACKAGE_DATA
|
|
20
|
+
}, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
18
21
|
channel: ANALYTICS_CHANNEL,
|
|
19
|
-
data: PACKAGE_DATA,
|
|
20
22
|
ErrorComponent: ErrorBoundaryFallback
|
|
21
23
|
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
22
24
|
fallback: LoaderFallback
|
|
23
|
-
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props))));
|
|
25
|
+
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props)))));
|
|
@@ -24,6 +24,7 @@ import { transformTimeStamp } from './transformTimeStamp';
|
|
|
24
24
|
import LinkSearchList, { testIds as listTestIds } from './link-search-list';
|
|
25
25
|
import LinkSearchError, { testIds as searchErrorTestIds } from './link-search-error';
|
|
26
26
|
import FormFooter, { testIds as formFooterTestIds } from './form-footer';
|
|
27
|
+
import { getDataSource } from './utils';
|
|
27
28
|
export const RECENT_SEARCH_LIST_SIZE = 5;
|
|
28
29
|
export const CONTACT_SUPPORT_LINK = 'https://support.atlassian.com/contact/';
|
|
29
30
|
export const testIds = {
|
|
@@ -110,6 +111,7 @@ function LinkPicker({
|
|
|
110
111
|
items,
|
|
111
112
|
isLoading,
|
|
112
113
|
isActivePlugin,
|
|
114
|
+
activePlugin,
|
|
113
115
|
tabs,
|
|
114
116
|
error,
|
|
115
117
|
retry,
|
|
@@ -139,10 +141,12 @@ function LinkPicker({
|
|
|
139
141
|
}
|
|
140
142
|
}, [onContentResize, items, isLoading, isActivePlugin, tabs]);
|
|
141
143
|
const handleChangeUrl = useCallback(e => {
|
|
144
|
+
/** Any on change event is triggered by manual input or paste, so source is null */
|
|
145
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
142
146
|
dispatch({
|
|
143
147
|
url: e.currentTarget.value
|
|
144
148
|
});
|
|
145
|
-
}, []);
|
|
149
|
+
}, [trackAttribute]);
|
|
146
150
|
const handleChangeText = useCallback(e => {
|
|
147
151
|
dispatch({
|
|
148
152
|
displayText: e.currentTarget.value
|
|
@@ -175,25 +179,32 @@ function LinkPicker({
|
|
|
175
179
|
break;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
|
|
182
|
+
const item = items[updatedIndex];
|
|
183
|
+
|
|
184
|
+
if ([KEY_CODE_ARROW_DOWN, KEY_CODE_ARROW_UP].includes(keyCode) && item) {
|
|
179
185
|
/**
|
|
180
186
|
* Manually track that the url has been updated using searchResult method
|
|
181
187
|
*/
|
|
182
|
-
trackAttribute('linkFieldContent', getLinkFieldContent(
|
|
188
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(item.url));
|
|
183
189
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
190
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(item, activePlugin));
|
|
184
191
|
dispatch({
|
|
185
192
|
activeIndex: updatedIndex,
|
|
186
193
|
selectedIndex: updatedIndex,
|
|
187
|
-
url:
|
|
194
|
+
url: item.url,
|
|
188
195
|
invalidUrl: false
|
|
189
196
|
});
|
|
190
197
|
}
|
|
191
|
-
}, [activeIndex, items, trackAttribute]);
|
|
198
|
+
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
192
199
|
const handleClear = useCallback(field => {
|
|
193
200
|
dispatch({
|
|
194
201
|
[field]: ''
|
|
195
202
|
});
|
|
196
203
|
}, []);
|
|
204
|
+
const handleUrlClear = useCallback(() => {
|
|
205
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
206
|
+
handleClear('url');
|
|
207
|
+
}, [trackAttribute, handleClear]);
|
|
197
208
|
const handleMouseEnterResultItem = useCallback(objectId => {
|
|
198
209
|
const index = items === null || items === void 0 ? void 0 : items.findIndex(item => item.objectId === objectId);
|
|
199
210
|
dispatch({
|
|
@@ -241,16 +252,17 @@ function LinkPicker({
|
|
|
241
252
|
url,
|
|
242
253
|
name
|
|
243
254
|
} = selectedItem;
|
|
244
|
-
dispatchEvent(new Event('submit'));
|
|
245
255
|
/**
|
|
246
256
|
* Manually track that the url has been updated using searchResult method
|
|
247
257
|
*/
|
|
248
258
|
|
|
259
|
+
dispatchEvent(new Event('submit'));
|
|
249
260
|
trackAttribute('linkFieldContent', getLinkFieldContent(url));
|
|
250
261
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
262
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(selectedItem, activePlugin));
|
|
251
263
|
handleInsert(url, name, 'typeAhead');
|
|
252
264
|
}
|
|
253
|
-
}, [handleInsert, trackAttribute, items]);
|
|
265
|
+
}, [handleInsert, trackAttribute, items, activePlugin]);
|
|
254
266
|
const handleSubmit = useCallback(event => {
|
|
255
267
|
event.preventDefault();
|
|
256
268
|
|
|
@@ -311,7 +323,7 @@ function LinkPicker({
|
|
|
311
323
|
"aria-activedescendant": ariaActiveDescendant,
|
|
312
324
|
"aria-describedby": screenReaderDescriptionId,
|
|
313
325
|
error: invalidUrl ? intl.formatMessage(messages.linkInvalid) : null,
|
|
314
|
-
onClear:
|
|
326
|
+
onClear: handleUrlClear,
|
|
315
327
|
onKeyDown: handleKeyDown,
|
|
316
328
|
onChange: handleChangeUrl
|
|
317
329
|
}), jsx(DisplayTextInputField, {
|
|
@@ -10,4 +10,13 @@ export const isRedoEvent = e => {
|
|
|
10
10
|
return (// ctrl + y for non-mac
|
|
11
11
|
!browser.mac && e.ctrlKey && e.keyCode === KeyYCode || browser.mac && e.metaKey && e.shiftKey && e.keyCode === KeyZCode || e.ctrlKey && e.shiftKey && e.keyCode === KeyZCode
|
|
12
12
|
);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve the data source for a link given the item and the plugin that resolved it
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const getDataSource = (item, plugin) => {
|
|
19
|
+
var _ref, _item$meta$source, _item$meta, _plugin$meta;
|
|
20
|
+
|
|
21
|
+
return (_ref = (_item$meta$source = (_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.source) !== null && _item$meta$source !== void 0 ? _item$meta$source : plugin === null || plugin === void 0 ? void 0 : (_plugin$meta = plugin.meta) === null || _plugin$meta === void 0 ? void 0 : _plugin$meta.source) !== null && _ref !== void 0 ? _ref : 'unknown';
|
|
13
22
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::e8a730530bb93e19d0b85114da0581c8>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
|
|
13
|
+
import React, { Component } from 'react';
|
|
14
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
15
|
+
import createEventPayload from '../../analytics.codegen';
|
|
16
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
17
|
+
export var BaseErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
18
|
+
_inherits(BaseErrorBoundary, _Component);
|
|
19
|
+
|
|
20
|
+
var _super = _createSuper(BaseErrorBoundary);
|
|
21
|
+
|
|
22
|
+
function BaseErrorBoundary(props) {
|
|
23
|
+
var _this;
|
|
24
|
+
|
|
25
|
+
_classCallCheck(this, BaseErrorBoundary);
|
|
26
|
+
|
|
27
|
+
_this = _super.call(this, props);
|
|
28
|
+
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "fireAnalytics", function (analyticsErrorPayload) {
|
|
30
|
+
var _window, _window$navigator, _analyticsErrorPayloa, _analyticsErrorPayloa2;
|
|
31
|
+
|
|
32
|
+
var _this$props = _this.props,
|
|
33
|
+
createAnalyticsEvent = _this$props.createAnalyticsEvent,
|
|
34
|
+
channel = _this$props.channel;
|
|
35
|
+
createAnalyticsEvent(createEventPayload('ui.linkPicker.unhandledErrorCaught', {
|
|
36
|
+
browserInfo: ((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent) || 'unknown',
|
|
37
|
+
error: analyticsErrorPayload.error.toString(),
|
|
38
|
+
componentStack: (_analyticsErrorPayloa = (_analyticsErrorPayloa2 = analyticsErrorPayload.info) === null || _analyticsErrorPayloa2 === void 0 ? void 0 : _analyticsErrorPayloa2.componentStack) !== null && _analyticsErrorPayloa !== void 0 ? _analyticsErrorPayloa : ''
|
|
39
|
+
})).fire(channel);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
_this.state = {
|
|
43
|
+
hasError: false
|
|
44
|
+
};
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_createClass(BaseErrorBoundary, [{
|
|
49
|
+
key: "componentDidCatch",
|
|
50
|
+
value: function componentDidCatch(error, info) {
|
|
51
|
+
var onError = this.props.onError;
|
|
52
|
+
var payload = {
|
|
53
|
+
error: error,
|
|
54
|
+
info: info
|
|
55
|
+
};
|
|
56
|
+
this.fireAnalytics(payload);
|
|
57
|
+
onError && onError(error, info);
|
|
58
|
+
this.setState({
|
|
59
|
+
hasError: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "render",
|
|
64
|
+
value: function render() {
|
|
65
|
+
var _this$props2 = this.props,
|
|
66
|
+
children = _this$props2.children,
|
|
67
|
+
ErrorComponent = _this$props2.ErrorComponent;
|
|
68
|
+
var hasError = this.state.hasError;
|
|
69
|
+
|
|
70
|
+
if (hasError && ErrorComponent) {
|
|
71
|
+
return /*#__PURE__*/React.createElement(ErrorComponent, null);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return children;
|
|
75
|
+
}
|
|
76
|
+
}]);
|
|
77
|
+
|
|
78
|
+
return BaseErrorBoundary;
|
|
79
|
+
}(Component);
|
|
80
|
+
var ErrorBoundary = withAnalyticsEvents()(BaseErrorBoundary);
|
|
81
|
+
export default ErrorBoundary;
|
package/dist/esm/ui/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
|
-
import { AnalyticsErrorBoundary } from '@atlaskit/analytics-next';
|
|
3
2
|
import { LazySuspense, lazyForPaint } from 'react-loosely-lazy';
|
|
3
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
4
4
|
import { COMPONENT_NAME, ANALYTICS_CHANNEL } from '../common/constants';
|
|
5
5
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
6
|
+
import ErrorBoundary from './error-boundary';
|
|
6
7
|
import { ErrorBoundaryFallback } from './error-boundary-fallback';
|
|
7
8
|
import { LoaderFallback } from './loader-fallback';
|
|
8
9
|
export var PACKAGE_DATA = {
|
|
@@ -17,11 +18,12 @@ var LazyLinkPicker = lazyForPaint(function () {
|
|
|
17
18
|
'./link-picker');
|
|
18
19
|
});
|
|
19
20
|
export var ComposedLinkPicker = /*#__PURE__*/memo(function (props) {
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
21
|
+
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
22
|
+
data: PACKAGE_DATA
|
|
23
|
+
}, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
21
24
|
channel: ANALYTICS_CHANNEL,
|
|
22
|
-
data: PACKAGE_DATA,
|
|
23
25
|
ErrorComponent: ErrorBoundaryFallback
|
|
24
26
|
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
25
27
|
fallback: LoaderFallback
|
|
26
|
-
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props)));
|
|
28
|
+
}, /*#__PURE__*/React.createElement(LazyLinkPicker, props))));
|
|
27
29
|
});
|
|
@@ -30,6 +30,7 @@ import { transformTimeStamp } from './transformTimeStamp';
|
|
|
30
30
|
import LinkSearchList, { testIds as listTestIds } from './link-search-list';
|
|
31
31
|
import LinkSearchError, { testIds as searchErrorTestIds } from './link-search-error';
|
|
32
32
|
import FormFooter, { testIds as formFooterTestIds } from './form-footer';
|
|
33
|
+
import { getDataSource } from './utils';
|
|
33
34
|
export var RECENT_SEARCH_LIST_SIZE = 5;
|
|
34
35
|
export var CONTACT_SUPPORT_LINK = 'https://support.atlassian.com/contact/';
|
|
35
36
|
export var testIds = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
@@ -116,6 +117,7 @@ function LinkPicker(_ref) {
|
|
|
116
117
|
items = _usePlugins.items,
|
|
117
118
|
isLoading = _usePlugins.isLoading,
|
|
118
119
|
isActivePlugin = _usePlugins.isActivePlugin,
|
|
120
|
+
activePlugin = _usePlugins.activePlugin,
|
|
119
121
|
tabs = _usePlugins.tabs,
|
|
120
122
|
error = _usePlugins.error,
|
|
121
123
|
retry = _usePlugins.retry,
|
|
@@ -146,10 +148,12 @@ function LinkPicker(_ref) {
|
|
|
146
148
|
}
|
|
147
149
|
}, [onContentResize, items, isLoading, isActivePlugin, tabs]);
|
|
148
150
|
var handleChangeUrl = useCallback(function (e) {
|
|
151
|
+
/** Any on change event is triggered by manual input or paste, so source is null */
|
|
152
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
149
153
|
dispatch({
|
|
150
154
|
url: e.currentTarget.value
|
|
151
155
|
});
|
|
152
|
-
}, []);
|
|
156
|
+
}, [trackAttribute]);
|
|
153
157
|
var handleChangeText = useCallback(function (e) {
|
|
154
158
|
dispatch({
|
|
155
159
|
displayText: e.currentTarget.value
|
|
@@ -180,23 +184,30 @@ function LinkPicker(_ref) {
|
|
|
180
184
|
break;
|
|
181
185
|
}
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
var item = items[updatedIndex];
|
|
188
|
+
|
|
189
|
+
if ([KEY_CODE_ARROW_DOWN, KEY_CODE_ARROW_UP].includes(keyCode) && item) {
|
|
184
190
|
/**
|
|
185
191
|
* Manually track that the url has been updated using searchResult method
|
|
186
192
|
*/
|
|
187
|
-
trackAttribute('linkFieldContent', getLinkFieldContent(
|
|
193
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(item.url));
|
|
188
194
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
195
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(item, activePlugin));
|
|
189
196
|
dispatch({
|
|
190
197
|
activeIndex: updatedIndex,
|
|
191
198
|
selectedIndex: updatedIndex,
|
|
192
|
-
url:
|
|
199
|
+
url: item.url,
|
|
193
200
|
invalidUrl: false
|
|
194
201
|
});
|
|
195
202
|
}
|
|
196
|
-
}, [activeIndex, items, trackAttribute]);
|
|
203
|
+
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
197
204
|
var handleClear = useCallback(function (field) {
|
|
198
205
|
dispatch(_defineProperty({}, field, ''));
|
|
199
206
|
}, []);
|
|
207
|
+
var handleUrlClear = useCallback(function () {
|
|
208
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
209
|
+
handleClear('url');
|
|
210
|
+
}, [trackAttribute, handleClear]);
|
|
200
211
|
var handleMouseEnterResultItem = useCallback(function (objectId) {
|
|
201
212
|
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
202
213
|
return item.objectId === objectId;
|
|
@@ -247,16 +258,17 @@ function LinkPicker(_ref) {
|
|
|
247
258
|
if (selectedItem) {
|
|
248
259
|
var _url = selectedItem.url,
|
|
249
260
|
name = selectedItem.name;
|
|
250
|
-
dispatchEvent(new Event('submit'));
|
|
251
261
|
/**
|
|
252
262
|
* Manually track that the url has been updated using searchResult method
|
|
253
263
|
*/
|
|
254
264
|
|
|
265
|
+
dispatchEvent(new Event('submit'));
|
|
255
266
|
trackAttribute('linkFieldContent', getLinkFieldContent(_url));
|
|
256
267
|
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
268
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(selectedItem, activePlugin));
|
|
257
269
|
handleInsert(_url, name, 'typeAhead');
|
|
258
270
|
}
|
|
259
|
-
}, [handleInsert, trackAttribute, items]);
|
|
271
|
+
}, [handleInsert, trackAttribute, items, activePlugin]);
|
|
260
272
|
var handleSubmit = useCallback(function (event) {
|
|
261
273
|
event.preventDefault();
|
|
262
274
|
|
|
@@ -317,7 +329,7 @@ function LinkPicker(_ref) {
|
|
|
317
329
|
"aria-activedescendant": ariaActiveDescendant,
|
|
318
330
|
"aria-describedby": screenReaderDescriptionId,
|
|
319
331
|
error: invalidUrl ? intl.formatMessage(messages.linkInvalid) : null,
|
|
320
|
-
onClear:
|
|
332
|
+
onClear: handleUrlClear,
|
|
321
333
|
onKeyDown: handleKeyDown,
|
|
322
334
|
onChange: handleChangeUrl
|
|
323
335
|
}), jsx(DisplayTextInputField, {
|
|
@@ -10,4 +10,13 @@ export var isRedoEvent = function isRedoEvent(e) {
|
|
|
10
10
|
return (// ctrl + y for non-mac
|
|
11
11
|
!browser.mac && e.ctrlKey && e.keyCode === KeyYCode || browser.mac && e.metaKey && e.shiftKey && e.keyCode === KeyZCode || e.ctrlKey && e.shiftKey && e.keyCode === KeyZCode
|
|
12
12
|
);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve the data source for a link given the item and the plugin that resolved it
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export var getDataSource = function getDataSource(item, plugin) {
|
|
19
|
+
var _ref, _item$meta$source, _item$meta, _plugin$meta;
|
|
20
|
+
|
|
21
|
+
return (_ref = (_item$meta$source = (_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.source) !== null && _item$meta$source !== void 0 ? _item$meta$source : plugin === null || plugin === void 0 ? void 0 : (_plugin$meta = plugin.meta) === null || _plugin$meta === void 0 ? void 0 : _plugin$meta.source) !== null && _ref !== void 0 ? _ref : 'unknown';
|
|
13
22
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::e8a730530bb93e19d0b85114da0581c8>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
|
+
export declare type PackageMetaDataType = {
|
|
10
|
+
packageName: '@atlaskit/link-picker';
|
|
11
|
+
packageVersion: string;
|
|
12
|
+
source: 'linkPicker';
|
|
13
|
+
componentName: 'linkPicker';
|
|
14
|
+
};
|
|
9
15
|
export declare type LinkPickerAnalyticsContextType = {
|
|
10
16
|
linkState: 'editLink' | 'newLink';
|
|
11
17
|
linkFieldContent: 'url' | 'text_string' | null;
|
|
12
18
|
linkFieldContentInputMethod: 'manual' | 'paste' | 'searchResult' | null;
|
|
19
|
+
linkFieldContentInputSource: string | null;
|
|
13
20
|
displayTextFieldContent: 'text_string' | null;
|
|
14
21
|
displayTextFieldContentInputMethod: 'manual' | 'paste' | null;
|
|
15
22
|
};
|
|
@@ -18,12 +25,18 @@ export declare type InlineDialogViewedLinkPickerAttributesType = {};
|
|
|
18
25
|
export declare type InlineDialogClosedLinkPickerAttributesType = {};
|
|
19
26
|
export declare type TextFieldUpdatedLinkFieldAttributesType = {};
|
|
20
27
|
export declare type TextFieldUpdatedDisplayTextFieldAttributesType = {};
|
|
28
|
+
export declare type LinkPickerUnhandledErrorCaughtAttributesType = {
|
|
29
|
+
browserInfo: string;
|
|
30
|
+
error: string;
|
|
31
|
+
componentStack: string | null;
|
|
32
|
+
};
|
|
21
33
|
declare type AnalyticsEventAttributes = {
|
|
22
34
|
'ui.form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
|
|
23
35
|
'ui.inlineDialog.viewed.linkPicker': InlineDialogViewedLinkPickerAttributesType;
|
|
24
36
|
'ui.inlineDialog.closed.linkPicker': InlineDialogClosedLinkPickerAttributesType;
|
|
25
37
|
'ui.textField.updated.linkField': TextFieldUpdatedLinkFieldAttributesType;
|
|
26
38
|
'ui.textField.updated.displayTextField': TextFieldUpdatedDisplayTextFieldAttributesType;
|
|
39
|
+
'ui.linkPicker.unhandledErrorCaught': LinkPickerUnhandledErrorCaughtAttributesType;
|
|
27
40
|
};
|
|
28
41
|
declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
|
|
29
42
|
eventType: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { Component, ReactNode } from 'react';
|
|
2
|
+
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
+
declare type ErrorBoundaryErrorInfo = {
|
|
4
|
+
componentStack: string;
|
|
5
|
+
};
|
|
6
|
+
export interface ErrorBoundaryProps extends WithAnalyticsEventsProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
channel: string;
|
|
9
|
+
ErrorComponent?: React.ComponentType;
|
|
10
|
+
onError?: (error: Error, info?: ErrorBoundaryErrorInfo) => void;
|
|
11
|
+
}
|
|
12
|
+
declare type ErrorBoundaryPayload = {
|
|
13
|
+
error: Error | string;
|
|
14
|
+
info?: ErrorBoundaryErrorInfo;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
declare type ErrorBoundaryState = {
|
|
18
|
+
hasError: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class BaseErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
21
|
+
constructor(props: ErrorBoundaryProps);
|
|
22
|
+
fireAnalytics: (analyticsErrorPayload: ErrorBoundaryPayload) => void;
|
|
23
|
+
componentDidCatch(error: Error, info?: ErrorBoundaryErrorInfo): void;
|
|
24
|
+
render(): React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
declare const ErrorBoundary: React.ForwardRefExoticComponent<Omit<ErrorBoundaryProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
|
27
|
+
export default ErrorBoundary;
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { PackageMetaDataType } from '../analytics.codegen';
|
|
2
3
|
import { LinkPickerProps } from './link-picker';
|
|
3
|
-
export declare const PACKAGE_DATA:
|
|
4
|
-
packageName: any;
|
|
5
|
-
packageVersion: any;
|
|
6
|
-
componentName: string;
|
|
7
|
-
source: string;
|
|
8
|
-
};
|
|
4
|
+
export declare const PACKAGE_DATA: PackageMetaDataType;
|
|
9
5
|
export declare const ComposedLinkPicker: React.MemoExoticComponent<(props: LinkPickerProps) => JSX.Element>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { LinkPickerPlugin, LinkSearchListItemData } from '../types';
|
|
2
3
|
export declare const isUndoEvent: (e: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
3
4
|
export declare const isRedoEvent: (e: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Retrieve the data source for a link given the item and the plugin that resolved it
|
|
7
|
+
*/
|
|
8
|
+
export declare const getDataSource: (item: LinkSearchListItemData, plugin?: LinkPickerPlugin | undefined) => string;
|
package/dist/types/ui/types.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface LinkSearchListItemData {
|
|
|
22
22
|
lastUpdatedDate?: Date;
|
|
23
23
|
/** Whether the result is pre-fetched from activity provider */
|
|
24
24
|
prefetch?: boolean;
|
|
25
|
+
/** Metadata about the result */
|
|
26
|
+
meta?: {
|
|
27
|
+
/** The data source that provided the result */
|
|
28
|
+
source?: string;
|
|
29
|
+
};
|
|
25
30
|
}
|
|
26
31
|
export declare type ListItemTimeStamp = {
|
|
27
32
|
pageAction: string;
|
|
@@ -43,5 +48,10 @@ export interface LinkPickerPlugin {
|
|
|
43
48
|
tabTitle?: string;
|
|
44
49
|
/** Render function to customise the UI that is displayed when an error occurs resolving results */
|
|
45
50
|
errorFallback?: LinkPickerPluginErrorFallback;
|
|
51
|
+
/** Metadata about the plugin */
|
|
52
|
+
meta?: {
|
|
53
|
+
/** The data source that provides all results provided by the plugin */
|
|
54
|
+
source?: string;
|
|
55
|
+
};
|
|
46
56
|
}
|
|
47
57
|
export declare type LinkPickerPluginErrorFallback = (error: unknown, retry: () => void) => ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
"@atlaskit/activity-provider": "^2.3.2",
|
|
58
58
|
"@atlaskit/docs": "*",
|
|
59
59
|
"@atlaskit/link-analytics": "^1.1.0",
|
|
60
|
-
"@atlaskit/link-test-helpers": "^1.
|
|
60
|
+
"@atlaskit/link-test-helpers": "^1.5.0",
|
|
61
61
|
"@atlaskit/popup": "^1.4.0",
|
|
62
62
|
"@atlaskit/ssr": "*",
|
|
63
63
|
"@atlaskit/toggle": "^12.5.0",
|
|
64
64
|
"@atlaskit/visual-regression": "*",
|
|
65
65
|
"@atlaskit/webdriver-runner": "*",
|
|
66
66
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
67
|
-
"@atlassian/link-picker-atlassian-plugin": "^
|
|
68
|
-
"@atlassian/link-picker-plugins": "^
|
|
67
|
+
"@atlassian/link-picker-atlassian-plugin": "^20.0.0",
|
|
68
|
+
"@atlassian/link-picker-plugins": "^7.0.0",
|
|
69
69
|
"@atlassian/recent-work-client": "^1.6.0",
|
|
70
70
|
"@atlassian/search-provider": "^2.3.0",
|
|
71
71
|
"@testing-library/dom": "^8.17.1",
|
package/report.api.md
CHANGED
|
@@ -28,6 +28,11 @@ export declare interface LinkPickerPlugin {
|
|
|
28
28
|
tabTitle?: string;
|
|
29
29
|
/** Render function to customise the UI that is displayed when an error occurs resolving results */
|
|
30
30
|
errorFallback?: LinkPickerPluginErrorFallback;
|
|
31
|
+
/** Metadata about the plugin */
|
|
32
|
+
meta?: {
|
|
33
|
+
/** The data source that provides all results provided by the plugin */
|
|
34
|
+
source?: string;
|
|
35
|
+
};
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export declare type LinkPickerPluginErrorFallback = (
|
|
@@ -83,6 +88,11 @@ export declare interface LinkSearchListItemData {
|
|
|
83
88
|
lastUpdatedDate?: Date;
|
|
84
89
|
/** Whether the result is pre-fetched from activity provider */
|
|
85
90
|
prefetch?: boolean;
|
|
91
|
+
/** Metadata about the result */
|
|
92
|
+
meta?: {
|
|
93
|
+
/** The data source that provided the result */
|
|
94
|
+
source?: string;
|
|
95
|
+
};
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
declare interface Meta {
|