@atlaskit/link-picker 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/{ui/error-boundary-fallback → common}/generic-error-svg/index.js +0 -0
- package/dist/cjs/{ui/error-boundary-fallback → common}/generic-error-svg/styled.js +0 -0
- package/dist/cjs/services/use-plugins/index.js +32 -35
- package/dist/cjs/services/use-search-query/index.js +41 -0
- package/dist/cjs/ui/error-boundary-fallback/index.js +1 -1
- package/dist/cjs/ui/link-picker/index.js +62 -40
- package/dist/cjs/ui/link-picker/link-search-error/index.js +27 -0
- package/dist/cjs/ui/link-picker/messages.js +10 -0
- package/dist/cjs/ui/link-picker/url.js +0 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/{ui/error-boundary-fallback → common}/generic-error-svg/index.js +0 -0
- package/dist/es2019/{ui/error-boundary-fallback → common}/generic-error-svg/styled.js +0 -0
- package/dist/es2019/services/use-plugins/index.js +28 -38
- package/dist/es2019/services/use-search-query/index.js +32 -0
- package/dist/es2019/ui/error-boundary-fallback/index.js +1 -1
- package/dist/es2019/ui/link-picker/index.js +56 -39
- package/dist/es2019/ui/link-picker/link-search-error/index.js +10 -0
- package/dist/es2019/ui/link-picker/messages.js +10 -0
- package/dist/es2019/ui/link-picker/url.js +0 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/{ui/error-boundary-fallback → common}/generic-error-svg/index.js +0 -0
- package/dist/esm/{ui/error-boundary-fallback → common}/generic-error-svg/styled.js +0 -0
- package/dist/esm/services/use-plugins/index.js +33 -35
- package/dist/esm/services/use-search-query/index.js +32 -0
- package/dist/esm/ui/error-boundary-fallback/index.js +1 -1
- package/dist/esm/ui/link-picker/index.js +58 -39
- package/dist/esm/ui/link-picker/link-search-error/index.js +14 -0
- package/dist/esm/ui/link-picker/messages.js +10 -0
- package/dist/esm/ui/link-picker/url.js +0 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/{ui/error-boundary-fallback → common}/generic-error-svg/index.d.ts +0 -0
- package/dist/types/{ui/error-boundary-fallback → common}/generic-error-svg/styled.d.ts +0 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/use-plugins/index.d.ts +6 -5
- package/dist/types/services/use-search-query/index.d.ts +3 -0
- package/dist/types/ui/link-picker/index.d.ts +5 -1
- package/dist/types/ui/link-picker/link-search-error/index.d.ts +4 -0
- package/dist/types/ui/link-picker/messages.d.ts +10 -0
- package/dist/types/ui/types.d.ts +5 -2
- package/package.json +6 -5
- package/report.api.md +21 -13
|
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
/** @jsx jsx */
|
|
10
|
-
import { useCallback, useReducer } from 'react';
|
|
10
|
+
import { Fragment, useCallback, useLayoutEffect, useReducer } from 'react';
|
|
11
11
|
import { jsx } from '@emotion/react';
|
|
12
12
|
import { useIntl, FormattedMessage } from 'react-intl-next';
|
|
13
13
|
import Button, { ButtonGroup } from '@atlaskit/button';
|
|
@@ -15,17 +15,20 @@ import { FormFooter } from '@atlaskit/form';
|
|
|
15
15
|
import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
|
|
16
16
|
import Tabs, { Tab, TabList } from '@atlaskit/tabs';
|
|
17
17
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
18
|
+
import { usePlugins } from '../../services/use-plugins';
|
|
19
|
+
import { useSearchQuery } from '../../services/use-search-query';
|
|
18
20
|
import { messages } from './messages';
|
|
19
21
|
import PanelTextInput from './text-input';
|
|
20
22
|
import LinkSearchList from './link-search-list';
|
|
21
23
|
import { normalizeUrl, isSafeUrl } from './url';
|
|
22
24
|
import { rootContainerStyles, searchIconStyles, listTitleStyles, tabsWrapperStyles } from './styled';
|
|
23
25
|
import { browser } from './browser';
|
|
24
|
-
import { transformTimeStamp } from './transformTimeStamp';
|
|
25
26
|
import Announcer from './announcer';
|
|
26
27
|
import LinkSearchNoResults from './link-search-no-results';
|
|
27
|
-
import {
|
|
28
|
+
import { transformTimeStamp } from './transformTimeStamp';
|
|
29
|
+
import LinkSearchError from './link-search-error';
|
|
28
30
|
export var RECENT_SEARCH_LIST_SIZE = 5;
|
|
31
|
+
export var CONTACT_SUPPORT_LINK = 'https://support.atlassian.com/contact/';
|
|
29
32
|
export var testIds = {
|
|
30
33
|
linkPicker: 'link-picker',
|
|
31
34
|
urlInputField: 'link-url',
|
|
@@ -41,7 +44,8 @@ export var testIds = {
|
|
|
41
44
|
searchResultLoadingIndicator: 'link-picker.results-loading-indicator',
|
|
42
45
|
urlError: 'link-error',
|
|
43
46
|
tabList: 'link-picker-tabs',
|
|
44
|
-
tabItem: 'link-picker-tab'
|
|
47
|
+
tabItem: 'link-picker-tab',
|
|
48
|
+
searchError: 'link-search-error'
|
|
45
49
|
};
|
|
46
50
|
var initState = {
|
|
47
51
|
url: '',
|
|
@@ -64,8 +68,11 @@ function reducer(state, payload) {
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
function LinkPicker(_ref) {
|
|
71
|
+
var _queryState$query, _items$length, _errorFallback;
|
|
72
|
+
|
|
67
73
|
var onSubmit = _ref.onSubmit,
|
|
68
74
|
onCancel = _ref.onCancel,
|
|
75
|
+
onContentResize = _ref.onContentResize,
|
|
69
76
|
plugins = _ref.plugins,
|
|
70
77
|
initUrl = _ref.url,
|
|
71
78
|
initDisplayText = _ref.displayText;
|
|
@@ -82,17 +89,28 @@ function LinkPicker(_ref) {
|
|
|
82
89
|
selectedIndex = state.selectedIndex,
|
|
83
90
|
url = state.url,
|
|
84
91
|
displayText = state.displayText,
|
|
85
|
-
invalidUrl = state.invalidUrl
|
|
86
|
-
|
|
92
|
+
invalidUrl = state.invalidUrl,
|
|
93
|
+
activeTab = state.activeTab;
|
|
87
94
|
var intl = useIntl();
|
|
95
|
+
var queryState = useSearchQuery(state);
|
|
88
96
|
|
|
89
|
-
var _usePlugins = usePlugins(
|
|
97
|
+
var _usePlugins = usePlugins(queryState, activeTab, plugins),
|
|
90
98
|
items = _usePlugins.items,
|
|
91
99
|
isLoading = _usePlugins.isLoading,
|
|
92
|
-
isSelectedItem = _usePlugins.isSelectedItem,
|
|
93
100
|
isActivePlugin = _usePlugins.isActivePlugin,
|
|
94
|
-
tabs = _usePlugins.tabs
|
|
101
|
+
tabs = _usePlugins.tabs,
|
|
102
|
+
error = _usePlugins.error,
|
|
103
|
+
retry = _usePlugins.retry,
|
|
104
|
+
errorFallback = _usePlugins.errorFallback;
|
|
95
105
|
|
|
106
|
+
var isEditing = !!initUrl;
|
|
107
|
+
var selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
|
|
108
|
+
var isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
|
|
109
|
+
useLayoutEffect(function () {
|
|
110
|
+
if (onContentResize) {
|
|
111
|
+
onContentResize();
|
|
112
|
+
}
|
|
113
|
+
}, [onContentResize, items, isLoading, isActivePlugin, tabs]);
|
|
96
114
|
var handleChangeUrl = useCallback(function (url) {
|
|
97
115
|
dispatch({
|
|
98
116
|
url: url
|
|
@@ -141,15 +159,15 @@ function LinkPicker(_ref) {
|
|
|
141
159
|
dispatch(_defineProperty({}, field, ''));
|
|
142
160
|
}, []);
|
|
143
161
|
var handleMouseEnterResultItem = useCallback(function (objectId) {
|
|
144
|
-
var index = findIndex(
|
|
162
|
+
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
145
163
|
return item.objectId === objectId;
|
|
146
164
|
});
|
|
147
165
|
dispatch({
|
|
148
|
-
activeIndex: index
|
|
166
|
+
activeIndex: index !== null && index !== void 0 ? index : -1
|
|
149
167
|
});
|
|
150
168
|
}, [items]);
|
|
151
169
|
var handleMouseLeaveResultItem = useCallback(function (objectId) {
|
|
152
|
-
var index = findIndex(
|
|
170
|
+
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
153
171
|
return item.objectId === objectId;
|
|
154
172
|
}); // This is to avoid updating index that was set by other mouseenter event
|
|
155
173
|
|
|
@@ -172,7 +190,7 @@ function LinkPicker(_ref) {
|
|
|
172
190
|
} : {}));
|
|
173
191
|
}, [displayText, onSubmit, state.url]);
|
|
174
192
|
var handleSelected = useCallback(function (objectId) {
|
|
175
|
-
var selectedItem = items.find(function (item) {
|
|
193
|
+
var selectedItem = items === null || items === void 0 ? void 0 : items.find(function (item) {
|
|
176
194
|
return item.objectId === objectId;
|
|
177
195
|
});
|
|
178
196
|
|
|
@@ -183,9 +201,7 @@ function LinkPicker(_ref) {
|
|
|
183
201
|
}
|
|
184
202
|
}, [handleInsert, items]);
|
|
185
203
|
var handleSubmit = useCallback(function () {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (isSelectedItem) {
|
|
204
|
+
if (isSelectedItem && selectedItem) {
|
|
189
205
|
return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
190
206
|
}
|
|
191
207
|
|
|
@@ -198,18 +214,18 @@ function LinkPicker(_ref) {
|
|
|
198
214
|
return dispatch({
|
|
199
215
|
invalidUrl: true
|
|
200
216
|
});
|
|
201
|
-
}, [handleInsert, isSelectedItem,
|
|
217
|
+
}, [handleInsert, isSelectedItem, selectedItem, url]);
|
|
202
218
|
var linkPlaceHolder = isActivePlugin ? messages.placeholder : messages.linkPlaceholder;
|
|
203
|
-
var linkListTitle =
|
|
219
|
+
var linkListTitle = (queryState === null || queryState === void 0 ? void 0 : (_queryState$query = queryState.query) === null || _queryState$query === void 0 ? void 0 : _queryState$query.length) !== 0 ? messages.titleResults : messages.titleRecentlyViewed;
|
|
204
220
|
var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
205
|
-
var noResults =
|
|
221
|
+
var noResults = (items === null || items === void 0 ? void 0 : items.length) === 0 && !error;
|
|
206
222
|
var screenReaderDescriptionId = 'search-recent-links-field-description';
|
|
207
223
|
var linkSearchListId = 'link-picker-search-list';
|
|
208
224
|
var ariaActiveDescendant = selectedIndex > -1 ? "link-search-list-item-".concat(selectedIndex) : ''; // Added workaround with a screen reader Announcer specifically for VoiceOver + Safari
|
|
209
225
|
// as the Aria design pattern for combobox does not work in this case
|
|
210
226
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
211
227
|
|
|
212
|
-
var screenReaderText = browser.safari && getScreenReaderText(items, selectedIndex, intl);
|
|
228
|
+
var screenReaderText = browser.safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
213
229
|
var searchIcon = isActivePlugin && jsx("span", {
|
|
214
230
|
css: searchIconStyles,
|
|
215
231
|
"data-testid": testIds.searchIcon
|
|
@@ -261,7 +277,7 @@ function LinkPicker(_ref) {
|
|
|
261
277
|
onSubmit: handleSubmit,
|
|
262
278
|
onKeyDown: handleKeyDown,
|
|
263
279
|
onChange: handleChangeText
|
|
264
|
-
}), tabs.length > 0 && jsx("div", {
|
|
280
|
+
}), queryState && jsx(Fragment, null, tabs.length > 0 && jsx("div", {
|
|
265
281
|
css: tabsWrapperStyles
|
|
266
282
|
}, jsx(Tabs, {
|
|
267
283
|
id: testIds.tabList,
|
|
@@ -279,7 +295,7 @@ function LinkPicker(_ref) {
|
|
|
279
295
|
key: tab.tabTitle,
|
|
280
296
|
testId: testIds.tabItem
|
|
281
297
|
}, tab.tabTitle);
|
|
282
|
-
})))), !!items.length && jsx("div", {
|
|
298
|
+
})))), !!(items !== null && items !== void 0 && items.length) && jsx("div", {
|
|
283
299
|
css: listTitleStyles,
|
|
284
300
|
id: testIds.resultListTitle,
|
|
285
301
|
"data-testid": testIds.resultListTitle
|
|
@@ -287,7 +303,7 @@ function LinkPicker(_ref) {
|
|
|
287
303
|
id: "fabric.smartcard.linkpicker.suggested.results"
|
|
288
304
|
}, url && jsx(FormattedMessage, _extends({}, messages.searchLinkResults, {
|
|
289
305
|
values: {
|
|
290
|
-
count: items.length
|
|
306
|
+
count: (_items$length = items === null || items === void 0 ? void 0 : items.length) !== null && _items$length !== void 0 ? _items$length : 0
|
|
291
307
|
},
|
|
292
308
|
"aria-live": "polite",
|
|
293
309
|
"aria-atomic": "true"
|
|
@@ -296,18 +312,34 @@ function LinkPicker(_ref) {
|
|
|
296
312
|
ariaControls: "fabric.smartcard.linkpicker.suggested.results",
|
|
297
313
|
id: linkSearchListId,
|
|
298
314
|
role: "listbox",
|
|
299
|
-
items: items,
|
|
315
|
+
items: items !== null && items !== void 0 ? items : [],
|
|
300
316
|
isLoading: isLoading,
|
|
301
317
|
selectedIndex: selectedIndex,
|
|
302
318
|
activeIndex: activeIndex,
|
|
303
319
|
onSelect: handleSelected,
|
|
304
320
|
onMouseEnter: handleMouseEnterResultItem,
|
|
305
321
|
onMouseLeave: handleMouseLeaveResultItem
|
|
306
|
-
}),
|
|
322
|
+
}), error && ((_errorFallback = errorFallback === null || errorFallback === void 0 ? void 0 : errorFallback(error, retry)) !== null && _errorFallback !== void 0 ? _errorFallback : jsx(LinkSearchError, {
|
|
323
|
+
testId: testIds.searchError,
|
|
324
|
+
header: intl.formatMessage(messages.searchErrorHeader),
|
|
325
|
+
description: jsx(FormattedMessage, _extends({}, messages.searchErrorDescription, {
|
|
326
|
+
values: {
|
|
327
|
+
a: function a(label) {
|
|
328
|
+
return jsx(Button, {
|
|
329
|
+
appearance: "link",
|
|
330
|
+
spacing: "none",
|
|
331
|
+
href: CONTACT_SUPPORT_LINK,
|
|
332
|
+
target: "_blank",
|
|
333
|
+
rel: "noopener noreferrer"
|
|
334
|
+
}, label);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}))
|
|
338
|
+
})), noResults && jsx(LinkSearchNoResults, {
|
|
307
339
|
testId: testIds.emptyResultPage,
|
|
308
340
|
header: intl.formatMessage(messages.noResults),
|
|
309
341
|
description: intl.formatMessage(messages.noResultsDescription)
|
|
310
|
-
}), jsx(FormFooter, {
|
|
342
|
+
})), jsx(FormFooter, {
|
|
311
343
|
align: "end"
|
|
312
344
|
}, jsx(ButtonGroup, null, jsx(Button, {
|
|
313
345
|
appearance: "default",
|
|
@@ -334,17 +366,4 @@ function getScreenReaderText(items, selectedIndex, intl) {
|
|
|
334
366
|
var formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
|
|
335
367
|
return [name, container, formattedDate].filter(Boolean).join(', ');
|
|
336
368
|
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function findIndex(array, predicate) {
|
|
340
|
-
var index = -1;
|
|
341
|
-
array.some(function (item, i) {
|
|
342
|
-
if (predicate(item)) {
|
|
343
|
-
index = i;
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return false;
|
|
348
|
-
});
|
|
349
|
-
return index;
|
|
350
369
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import EmptyState from '@atlaskit/empty-state';
|
|
4
|
+
import GenericErrorSVG from '../../../common/generic-error-svg';
|
|
5
|
+
|
|
6
|
+
var LinkSearchError = function LinkSearchError(props) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(EmptyState, _extends({}, props, {
|
|
8
|
+
renderImage: function renderImage() {
|
|
9
|
+
return /*#__PURE__*/React.createElement(GenericErrorSVG, null);
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default LinkSearchError;
|
|
@@ -104,5 +104,15 @@ export var messages = defineMessages({
|
|
|
104
104
|
id: 'fabric.linkPicker.button.save',
|
|
105
105
|
defaultMessage: 'Save',
|
|
106
106
|
description: 'Button to save edited link'
|
|
107
|
+
},
|
|
108
|
+
searchErrorHeader: {
|
|
109
|
+
id: 'fabric.linkPicker.search.error.heading',
|
|
110
|
+
defaultMessage: 'We’re having trouble loading data.',
|
|
111
|
+
description: 'Heading message shown when a search throws an error'
|
|
112
|
+
},
|
|
113
|
+
searchErrorDescription: {
|
|
114
|
+
id: 'fabric.linkPicker.search.error.description',
|
|
115
|
+
defaultMessage: 'Refresh the page, or contact <a>Atlassian Support</a> if this keeps happening.',
|
|
116
|
+
description: 'Describes possible actions when search throws an error'
|
|
107
117
|
}
|
|
108
118
|
});
|
|
@@ -64,11 +64,6 @@ var linkifyMatch = function linkifyMatch(text) {
|
|
|
64
64
|
|
|
65
65
|
export var isSafeUrl = function isSafeUrl(url) {
|
|
66
66
|
var urlTrimmed = url.trim();
|
|
67
|
-
|
|
68
|
-
if (urlTrimmed.length === 0) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
67
|
return whitelistedURLPatterns.some(function (p) {
|
|
73
68
|
return p.test(urlTrimmed);
|
|
74
69
|
});
|
package/dist/esm/version.json
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ComposedLinkPicker as LinkPicker } from './ui';
|
|
2
2
|
export type { LinkPickerProps } from './ui/link-picker';
|
|
3
|
-
export type { LinkInputType, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, } from './ui/types';
|
|
3
|
+
export type { LinkInputType, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, LinkPickerPluginErrorFallback, } from './ui/types';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LinkPickerPlugin, LinkSearchListItemData } from '../../ui/types';
|
|
1
|
+
import { LinkPickerPlugin, LinkPickerPluginErrorFallback, LinkPickerState, LinkSearchListItemData } from '../../ui/types';
|
|
3
2
|
export interface LinkPickerPluginsService {
|
|
4
|
-
items: LinkSearchListItemData[];
|
|
3
|
+
items: LinkSearchListItemData[] | null;
|
|
5
4
|
isLoading: boolean;
|
|
6
|
-
isSelectedItem: boolean;
|
|
7
5
|
isActivePlugin: boolean;
|
|
8
6
|
tabs: {
|
|
9
7
|
tabTitle: string;
|
|
10
8
|
}[];
|
|
9
|
+
error: unknown | null;
|
|
10
|
+
retry: () => void;
|
|
11
|
+
errorFallback?: LinkPickerPluginErrorFallback;
|
|
11
12
|
}
|
|
12
|
-
export declare function usePlugins(state:
|
|
13
|
+
export declare function usePlugins(state: LinkPickerState | null, activeTab: number, plugins?: LinkPickerPlugin[]): LinkPickerPluginsService;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
2
|
import { LinkInputType, LinkPickerPlugin } from '../types';
|
|
3
3
|
export declare const RECENT_SEARCH_LIST_SIZE = 5;
|
|
4
|
+
export declare const CONTACT_SUPPORT_LINK = "https://support.atlassian.com/contact/";
|
|
4
5
|
export declare const testIds: {
|
|
5
6
|
linkPicker: string;
|
|
6
7
|
urlInputField: string;
|
|
@@ -17,6 +18,7 @@ export declare const testIds: {
|
|
|
17
18
|
urlError: string;
|
|
18
19
|
tabList: string;
|
|
19
20
|
tabItem: string;
|
|
21
|
+
searchError: string;
|
|
20
22
|
};
|
|
21
23
|
interface Meta {
|
|
22
24
|
/** Indicates how the link was picked. */
|
|
@@ -44,6 +46,8 @@ export interface LinkPickerProps {
|
|
|
44
46
|
onSubmit: (arg: OnSubmitParameter) => void;
|
|
45
47
|
/** Callback to fire when the cancel button is clicked. */
|
|
46
48
|
onCancel: () => void;
|
|
49
|
+
/** Callback to fire when content is changed inside the link picker e.g. items, when loading, tabs */
|
|
50
|
+
onContentResize?: () => void;
|
|
47
51
|
/** The url of the linked resource for editing. */
|
|
48
52
|
url?: string;
|
|
49
53
|
/** The desired text to be displayed alternatively to the title of the linked resource for editing. */
|
|
@@ -59,5 +63,5 @@ export interface PickerState {
|
|
|
59
63
|
invalidUrl: boolean;
|
|
60
64
|
activeTab: number;
|
|
61
65
|
}
|
|
62
|
-
declare function LinkPicker({ onSubmit, onCancel, plugins, url: initUrl, displayText: initDisplayText, }: LinkPickerProps): jsx.JSX.Element;
|
|
66
|
+
declare function LinkPicker({ onSubmit, onCancel, onContentResize, plugins, url: initUrl, displayText: initDisplayText, }: LinkPickerProps): jsx.JSX.Element;
|
|
63
67
|
export default LinkPicker;
|
|
@@ -104,4 +104,14 @@ export declare const messages: {
|
|
|
104
104
|
defaultMessage: string;
|
|
105
105
|
description: string;
|
|
106
106
|
};
|
|
107
|
+
searchErrorHeader: {
|
|
108
|
+
id: string;
|
|
109
|
+
defaultMessage: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
searchErrorDescription: {
|
|
113
|
+
id: string;
|
|
114
|
+
defaultMessage: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
107
117
|
};
|
package/dist/types/ui/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { MessageDescriptor } from 'react-intl-next';
|
|
3
3
|
export declare type LinkInputType = 'manual' | 'typeAhead';
|
|
4
4
|
export interface LinkSearchListItemData {
|
|
@@ -36,9 +36,12 @@ export interface ResolveResult {
|
|
|
36
36
|
data: LinkSearchListItemData[];
|
|
37
37
|
}
|
|
38
38
|
export interface LinkPickerPlugin {
|
|
39
|
+
resolve: (state: LinkPickerState) => Promise<ResolveResult> | AsyncGenerator<ResolveResult, ResolveResult>;
|
|
39
40
|
/** Uniquely identify the tab */
|
|
40
41
|
tabKey?: string;
|
|
41
42
|
/** Human-readable label for the plugin */
|
|
42
43
|
tabTitle?: string;
|
|
43
|
-
|
|
44
|
+
/** Render function to customise the UI that is displayed when an error occurs resolving results */
|
|
45
|
+
errorFallback?: LinkPickerPluginErrorFallback;
|
|
44
46
|
}
|
|
47
|
+
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.7.0",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -54,14 +54,15 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@atlaskit/activity-provider": "^2.3.2",
|
|
56
56
|
"@atlaskit/docs": "*",
|
|
57
|
-
"@atlaskit/link-test-helpers": "^1.
|
|
58
|
-
"@atlaskit/popup": "^1.
|
|
57
|
+
"@atlaskit/link-test-helpers": "^1.4.0",
|
|
58
|
+
"@atlaskit/popup": "^1.4.0",
|
|
59
59
|
"@atlaskit/ssr": "*",
|
|
60
|
+
"@atlaskit/toggle": "^12.4.0",
|
|
60
61
|
"@atlaskit/visual-regression": "*",
|
|
61
62
|
"@atlaskit/webdriver-runner": "*",
|
|
62
63
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
63
|
-
"@atlassian/link-picker-atlassian-plugin": "^
|
|
64
|
-
"@atlassian/link-picker-plugins": "^
|
|
64
|
+
"@atlassian/link-picker-atlassian-plugin": "^17.0.0",
|
|
65
|
+
"@atlassian/link-picker-plugins": "^4.0.0",
|
|
65
66
|
"@atlassian/search-provider": "^2.3.0",
|
|
66
67
|
"@testing-library/dom": "^7.7.3",
|
|
67
68
|
"@testing-library/jest-dom": "^4.1.0",
|
package/report.api.md
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/link-picker"
|
|
1
|
+
## API Report File for "@atlaskit/link-picker".
|
|
2
2
|
|
|
3
|
-
> Do not edit this file.
|
|
3
|
+
> Do not edit this file. This report is auto-generated by [API Extractor](https://api-extractor.com/).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/// <reference types="react" />
|
|
5
|
+
[Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
6
|
|
|
7
|
+
```ts
|
|
8
8
|
import { MessageDescriptor } from 'react-intl-next';
|
|
9
9
|
import { default as React_2 } from 'react';
|
|
10
|
-
import {
|
|
11
|
-
import { WrappedComponentProps } from 'react-intl-next';
|
|
10
|
+
import { ReactNode } from 'react';
|
|
12
11
|
|
|
13
12
|
export declare type LinkInputType = 'manual' | 'typeAhead';
|
|
14
13
|
|
|
15
|
-
export declare const LinkPicker: React_2.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
WrappedComponent: React_2.ComponentType<
|
|
19
|
-
WrappedComponentProps<'intl'> & LinkPickerProps
|
|
20
|
-
>;
|
|
21
|
-
};
|
|
14
|
+
export declare const LinkPicker: React_2.MemoExoticComponent<(
|
|
15
|
+
props: LinkPickerProps,
|
|
16
|
+
) => JSX.Element>;
|
|
22
17
|
|
|
23
18
|
export declare interface LinkPickerPlugin {
|
|
24
19
|
resolve: (
|
|
25
20
|
state: LinkPickerState,
|
|
26
21
|
) => Promise<ResolveResult> | AsyncGenerator<ResolveResult, ResolveResult>;
|
|
22
|
+
/** Uniquely identify the tab */
|
|
23
|
+
tabKey?: string;
|
|
24
|
+
/** Human-readable label for the plugin */
|
|
25
|
+
tabTitle?: string;
|
|
26
|
+
/** Render function to customise the UI that is displayed when an error occurs resolving results */
|
|
27
|
+
errorFallback?: LinkPickerPluginErrorFallback;
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
export declare type LinkPickerPluginErrorFallback = (
|
|
31
|
+
error: unknown,
|
|
32
|
+
retry: () => void,
|
|
33
|
+
) => ReactNode;
|
|
34
|
+
|
|
29
35
|
export declare interface LinkPickerProps {
|
|
30
36
|
/** Callback to fire on form submission. */
|
|
31
37
|
onSubmit: (arg: OnSubmitParameter) => void;
|
|
32
38
|
/** Callback to fire when the cancel button is clicked. */
|
|
33
39
|
onCancel: () => void;
|
|
40
|
+
/** Callback to fire when content is changed inside the link picker e.g. items, when loading, tabs */
|
|
41
|
+
onContentResize?: () => void;
|
|
34
42
|
/** The url of the linked resource for editing. */
|
|
35
43
|
url?: string;
|
|
36
44
|
/** The desired text to be displayed alternatively to the title of the linked resource for editing. */
|