@atlaskit/link-picker 0.9.0 → 1.0.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/link-picker.js +60 -39
- package/dist/cjs/ui/{LinkSearchList.js → link-search-list/index.js} +15 -25
- package/dist/cjs/ui/link-search-list/styled.js +21 -0
- package/dist/cjs/ui/{LinkSearchListItem.js → list-item/index.js} +26 -24
- package/dist/cjs/ui/list-item/styled.js +59 -0
- package/dist/cjs/ui/styled.js +32 -0
- package/dist/cjs/ui/{PanelTextInput.js → text-input/index.js} +14 -17
- package/dist/cjs/ui/text-input/styled.js +25 -0
- package/dist/cjs/utils.js +1 -14
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/ui/link-picker.js +24 -13
- package/dist/es2019/ui/{LinkSearchList.js → link-search-list/index.js} +14 -19
- package/dist/es2019/ui/link-search-list/styled.js +13 -0
- package/dist/es2019/ui/list-item/index.js +88 -0
- package/dist/es2019/ui/list-item/styled.js +65 -0
- package/dist/es2019/ui/styled.js +28 -0
- package/dist/es2019/ui/{PanelTextInput.js → text-input/index.js} +15 -9
- package/dist/es2019/ui/text-input/styled.js +15 -0
- package/dist/es2019/utils.js +0 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/ui/link-picker.js +47 -26
- package/dist/esm/ui/{LinkSearchList.js → link-search-list/index.js} +14 -13
- package/dist/esm/ui/link-search-list/styled.js +8 -0
- package/dist/esm/ui/{LinkSearchListItem.js → list-item/index.js} +25 -23
- package/dist/esm/ui/list-item/styled.js +37 -0
- package/dist/esm/ui/styled.js +16 -0
- package/dist/esm/ui/{PanelTextInput.js → text-input/index.js} +15 -9
- package/dist/esm/ui/text-input/styled.js +10 -0
- package/dist/esm/utils.js +0 -11
- package/dist/esm/version.json +1 -1
- package/dist/types/types.d.ts +4 -1
- package/dist/types/ui/{LinkSearchList.d.ts → link-search-list/index.d.ts} +4 -4
- package/dist/types/ui/link-search-list/styled.d.ts +3 -0
- package/dist/types/ui/{LinkSearchListItem.d.ts → list-item/index.d.ts} +1 -1
- package/dist/types/ui/list-item/styled.d.ts +7 -0
- package/dist/types/ui/styled.d.ts +4 -0
- package/dist/types/ui/{PanelTextInput.d.ts → text-input/index.d.ts} +2 -2
- package/dist/types/ui/text-input/styled.d.ts +2 -0
- package/dist/types/utils.d.ts +0 -1
- package/example-helpers/mock-data.ts +4 -0
- package/package.json +6 -5
- package/dist/cjs/styles.js +0 -90
- package/dist/es2019/styles.js +0 -93
- package/dist/es2019/ui/LinkSearchListItem.js +0 -88
- package/dist/esm/styles.js +0 -46
- package/dist/types/styles.d.ts +0 -18
package/dist/cjs/utils.js
CHANGED
|
@@ -3,23 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isUndoEvent = exports.isRedoEvent = void 0;
|
|
7
7
|
|
|
8
8
|
var _browser = require("./browser");
|
|
9
9
|
|
|
10
|
-
var relativeFontSizeToBase16 = function relativeFontSizeToBase16(px) {
|
|
11
|
-
if (typeof px === 'string') {
|
|
12
|
-
px = parseInt(px);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (isNaN(px)) {
|
|
16
|
-
throw new Error("Invalid font size: '".concat(px, "'"));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return "".concat(px / 16, "rem");
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
exports.relativeFontSizeToBase16 = relativeFontSizeToBase16;
|
|
23
10
|
var KeyZCode = 90;
|
|
24
11
|
var KeyYCode = 89;
|
|
25
12
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,13 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React, { PureComponent } from 'react';
|
|
5
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
import { messages } from '../messages';
|
|
8
|
-
import PanelTextInput from './
|
|
9
|
-
import LinkSearchList from './
|
|
8
|
+
import PanelTextInput from './text-input';
|
|
9
|
+
import LinkSearchList from './link-search-list';
|
|
10
10
|
import { normalizeUrl, isSafeUrl } from '../url';
|
|
11
|
-
import { recentListStyles,
|
|
11
|
+
import { recentListStyles, containerStyles, searchIconStyles, listTitleStyles } from './styled';
|
|
12
12
|
import { browser } from '../browser';
|
|
13
13
|
import { transformTimeStamp } from '../transformTimeStamp';
|
|
14
14
|
import Announcer from './announcer';
|
|
@@ -319,17 +319,26 @@ class LinkPicker extends PureComponent {
|
|
|
319
319
|
|
|
320
320
|
try {
|
|
321
321
|
while (queryVersion === this.queryVersion) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
let done = false;
|
|
323
|
+
let value;
|
|
324
|
+
|
|
325
|
+
if (updates instanceof Promise) {
|
|
326
|
+
done = true;
|
|
327
|
+
value = await updates;
|
|
328
|
+
} else {
|
|
329
|
+
var _result$done;
|
|
330
|
+
|
|
331
|
+
const result = await updates.next();
|
|
332
|
+
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
333
|
+
value = result.value;
|
|
334
|
+
}
|
|
326
335
|
|
|
327
336
|
if (queryVersion !== this.queryVersion) {
|
|
328
337
|
return;
|
|
329
338
|
}
|
|
330
339
|
|
|
331
340
|
this.setState({
|
|
332
|
-
items: limit(value),
|
|
341
|
+
items: limit(value.data),
|
|
333
342
|
isLoading: !done
|
|
334
343
|
});
|
|
335
344
|
|
|
@@ -370,7 +379,8 @@ class LinkPicker extends PureComponent {
|
|
|
370
379
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
371
380
|
|
|
372
381
|
const screenReaderText = browser.safari && this.getScreenReaderText();
|
|
373
|
-
const searchIcon = activePlugin && jsx(
|
|
382
|
+
const searchIcon = activePlugin && jsx("span", {
|
|
383
|
+
css: searchIconStyles,
|
|
374
384
|
"data-testid": "link-picker-search-icon"
|
|
375
385
|
}, jsx(EditorSearchIcon, {
|
|
376
386
|
size: "medium",
|
|
@@ -380,8 +390,9 @@ class LinkPicker extends PureComponent {
|
|
|
380
390
|
"data-testid": "link-picker",
|
|
381
391
|
className: "recent-list",
|
|
382
392
|
css: recentListStyles
|
|
383
|
-
}, jsx(
|
|
384
|
-
|
|
393
|
+
}, jsx("div", {
|
|
394
|
+
css: containerStyles,
|
|
395
|
+
ref: this.wrapperRef
|
|
385
396
|
}, screenReaderText && jsx(Announcer, {
|
|
386
397
|
ariaLive: "assertive",
|
|
387
398
|
text: screenReaderText,
|
|
@@ -425,7 +436,7 @@ class LinkPicker extends PureComponent {
|
|
|
425
436
|
onClear: this.handleClearDisplayText,
|
|
426
437
|
clearLabel: formatMessage(messages.clearText)
|
|
427
438
|
}), !!items.length && jsx("div", {
|
|
428
|
-
css:
|
|
439
|
+
css: listTitleStyles,
|
|
429
440
|
id: "link-picker-list-title",
|
|
430
441
|
"data-testid": "link-picker-list-title"
|
|
431
442
|
}, formatMessage(this.state.url ? messages.titleResults : messages.titleRecentlyViewed)), jsx(VisuallyHidden, null, jsx("span", {
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
2
|
import { PureComponent } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
3
4
|
import Spinner from '@atlaskit/spinner';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const ListContainer = styled.div`
|
|
7
|
-
padding-top: 0;
|
|
8
|
-
`;
|
|
9
|
-
const SpinnerContainer = styled.div`
|
|
10
|
-
text-align: center;
|
|
11
|
-
min-height: 80px;
|
|
12
|
-
margin-top: 30px;
|
|
13
|
-
`;
|
|
14
|
-
export const List = styled.ul`
|
|
15
|
-
padding: 0;
|
|
16
|
-
list-style: none;
|
|
17
|
-
`;
|
|
5
|
+
import LinkSearchListItem from '../list-item';
|
|
6
|
+
import { listContainerStyles, spinnerContainerStyles, listStyles } from './styled';
|
|
18
7
|
export default class LinkSearchList extends PureComponent {
|
|
19
8
|
render() {
|
|
20
9
|
const {
|
|
@@ -34,12 +23,14 @@ export default class LinkSearchList extends PureComponent {
|
|
|
34
23
|
let loadingContent;
|
|
35
24
|
|
|
36
25
|
if (items && items.length > 0) {
|
|
37
|
-
itemsContent =
|
|
26
|
+
itemsContent = jsx("ul", {
|
|
27
|
+
"data-testid": "link-search-list",
|
|
28
|
+
css: listStyles,
|
|
38
29
|
id: id,
|
|
39
30
|
role: role,
|
|
40
31
|
"aria-controls": ariaControls,
|
|
41
32
|
"aria-labelledby": ariaLabelledBy
|
|
42
|
-
}, items.map((item, index) =>
|
|
33
|
+
}, items.map((item, index) => jsx(LinkSearchListItem, {
|
|
43
34
|
id: `link-search-list-item-${index}`,
|
|
44
35
|
role: role && 'option',
|
|
45
36
|
item: item,
|
|
@@ -53,13 +44,17 @@ export default class LinkSearchList extends PureComponent {
|
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
if (isLoading) {
|
|
56
|
-
loadingContent =
|
|
47
|
+
loadingContent = jsx("div", {
|
|
48
|
+
css: spinnerContainerStyles
|
|
49
|
+
}, jsx(Spinner, {
|
|
57
50
|
testId: "link-picker.results-loading-indicator",
|
|
58
51
|
size: "medium"
|
|
59
52
|
}));
|
|
60
53
|
}
|
|
61
54
|
|
|
62
|
-
return
|
|
55
|
+
return jsx("div", {
|
|
56
|
+
css: listContainerStyles
|
|
57
|
+
}, itemsContent, loadingContent);
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
export const listContainerStyles = css`
|
|
3
|
+
padding-top: 0;
|
|
4
|
+
`;
|
|
5
|
+
export const spinnerContainerStyles = css`
|
|
6
|
+
text-align: center;
|
|
7
|
+
min-height: 80px;
|
|
8
|
+
margin-top: 30px;
|
|
9
|
+
`;
|
|
10
|
+
export const listStyles = css`
|
|
11
|
+
padding: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
`;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { injectIntl } from 'react-intl-next';
|
|
5
|
+
import { transformTimeStamp } from '../../transformTimeStamp';
|
|
6
|
+
import { itemNameStyles, itemIconStyles, listItemContextStyles, listItemNameStyles, composeListItemStyles, imgStyles } from './styled';
|
|
7
|
+
|
|
8
|
+
const LinkSearchListItem = ({
|
|
9
|
+
item,
|
|
10
|
+
selected,
|
|
11
|
+
active,
|
|
12
|
+
id,
|
|
13
|
+
role,
|
|
14
|
+
intl,
|
|
15
|
+
onSelect,
|
|
16
|
+
onMouseEnter,
|
|
17
|
+
onMouseLeave
|
|
18
|
+
}) => {
|
|
19
|
+
const handleSelect = () => onSelect(item.objectId);
|
|
20
|
+
|
|
21
|
+
const handleMouseEnter = () => onMouseEnter(item.objectId);
|
|
22
|
+
|
|
23
|
+
const handleMouseLeave = () => onMouseLeave(item.objectId);
|
|
24
|
+
|
|
25
|
+
const container = item.container || null;
|
|
26
|
+
const date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
|
|
27
|
+
return jsx("div", {
|
|
28
|
+
css: composeListItemStyles(active, selected),
|
|
29
|
+
role: role,
|
|
30
|
+
id: id,
|
|
31
|
+
"aria-selected": selected,
|
|
32
|
+
"data-testid": "link-search-list-item",
|
|
33
|
+
onMouseEnter: handleMouseEnter,
|
|
34
|
+
onMouseLeave: handleMouseLeave,
|
|
35
|
+
onClick: handleSelect
|
|
36
|
+
}, jsx(ListItemIcon, {
|
|
37
|
+
item: item,
|
|
38
|
+
intl: intl
|
|
39
|
+
}), jsx("div", {
|
|
40
|
+
css: itemNameStyles
|
|
41
|
+
}, jsx("div", {
|
|
42
|
+
"data-testid": "link-search-list-item-title",
|
|
43
|
+
css: listItemNameStyles
|
|
44
|
+
}, item.name), jsx("div", {
|
|
45
|
+
"data-testid": "link-search-list-item-subtitle",
|
|
46
|
+
css: listItemContextStyles
|
|
47
|
+
}, container, container && date && jsx(Fragment, null, "\xA0 \u2022\xA0 "), date && jsx(Fragment, null, formatDate(date)))));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default injectIntl(LinkSearchListItem);
|
|
51
|
+
|
|
52
|
+
const formatDate = date => {
|
|
53
|
+
return [date.pageAction, date.dateString, date.timeSince].filter(Boolean).join(' ');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const ListItemIcon = props => {
|
|
57
|
+
const {
|
|
58
|
+
item,
|
|
59
|
+
intl
|
|
60
|
+
} = props;
|
|
61
|
+
const {
|
|
62
|
+
icon,
|
|
63
|
+
iconAlt
|
|
64
|
+
} = item;
|
|
65
|
+
|
|
66
|
+
if (!icon) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const alt = typeof iconAlt === 'string' ? iconAlt : intl.formatMessage(iconAlt);
|
|
71
|
+
|
|
72
|
+
if (typeof icon !== 'string') {
|
|
73
|
+
const Glyph = icon;
|
|
74
|
+
return jsx("span", {
|
|
75
|
+
css: itemIconStyles
|
|
76
|
+
}, jsx(Glyph, {
|
|
77
|
+
alt: alt
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return jsx("span", {
|
|
82
|
+
css: itemIconStyles
|
|
83
|
+
}, jsx("img", {
|
|
84
|
+
src: icon,
|
|
85
|
+
alt: alt,
|
|
86
|
+
css: imgStyles
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { token } from '@atlaskit/tokens';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { gridSize } from '@atlaskit/theme/constants'; // AFP-2532 TODO: Fix automatic suppressions below
|
|
5
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
6
|
+
|
|
7
|
+
import { fontSizeSmall, fontSize } from '@atlaskit/theme';
|
|
8
|
+
export const relativeFontSizeToBase16 = px => {
|
|
9
|
+
if (typeof px === 'string') {
|
|
10
|
+
px = parseInt(px);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (isNaN(px)) {
|
|
14
|
+
throw new Error(`Invalid font size: '${px}'`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return `${px / 16}rem`;
|
|
18
|
+
};
|
|
19
|
+
const listItemBaseStyles = css`
|
|
20
|
+
display: flex;
|
|
21
|
+
padding: ${gridSize()}px ${gridSize() * 2}px;
|
|
22
|
+
margin: 0 -${gridSize() * 2}px;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
`;
|
|
25
|
+
const listItemBoxShadow = css`
|
|
26
|
+
box-shadow: inset 2px 0px 0px ${token('color.border.selected', B400)};
|
|
27
|
+
`;
|
|
28
|
+
const listItemActive = css`
|
|
29
|
+
background-color: ${token('color.background.neutral.subtle.hovered', N20)};
|
|
30
|
+
`;
|
|
31
|
+
const listItemSelected = css`
|
|
32
|
+
background-color: ${token('color.background.selected', B50)};
|
|
33
|
+
`;
|
|
34
|
+
export const composeListItemStyles = (active = false, selected = false) => {
|
|
35
|
+
const hasShadow = active || selected;
|
|
36
|
+
return css`
|
|
37
|
+
${listItemBaseStyles};
|
|
38
|
+
${active && listItemActive};
|
|
39
|
+
${selected && listItemSelected};
|
|
40
|
+
${hasShadow && listItemBoxShadow};
|
|
41
|
+
`;
|
|
42
|
+
};
|
|
43
|
+
export const itemNameStyles = css`
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
`;
|
|
46
|
+
export const listItemNameStyles = css`
|
|
47
|
+
color: ${token('color.text', N800)};
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
text-overflow: ellipsis;
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
line-height: 20px;
|
|
52
|
+
`;
|
|
53
|
+
export const listItemContextStyles = css`
|
|
54
|
+
color: ${token('color.text', N300)};
|
|
55
|
+
font-size: ${relativeFontSizeToBase16(fontSizeSmall())};
|
|
56
|
+
line-height: ${fontSize()}px;
|
|
57
|
+
`;
|
|
58
|
+
export const itemIconStyles = css`
|
|
59
|
+
min-width: ${gridSize() * 2}px;
|
|
60
|
+
margin-top: 3px;
|
|
61
|
+
margin-right: 12px;
|
|
62
|
+
`;
|
|
63
|
+
export const imgStyles = css`
|
|
64
|
+
max-width: ${gridSize() * 2}px;
|
|
65
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { token } from '@atlaskit/tokens';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { N500 } from '@atlaskit/theme/colors'; // AFP-2532 TODO: Fix automatic suppressions below
|
|
4
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
+
|
|
6
|
+
import { typography } from '@atlaskit/theme';
|
|
7
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
8
|
+
const LINK_PICKER_WIDTH_IN_PX = 342;
|
|
9
|
+
export const recentListStyles = css`
|
|
10
|
+
width: ${LINK_PICKER_WIDTH_IN_PX}px;
|
|
11
|
+
`;
|
|
12
|
+
export const containerStyles = css`
|
|
13
|
+
padding: ${gridSize() * 2}px;
|
|
14
|
+
width: 100%;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
line-height: initial;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
`;
|
|
19
|
+
export const searchIconStyles = css`
|
|
20
|
+
margin-left: ${gridSize() / 2}px;
|
|
21
|
+
color: ${token('color.icon', N500)};
|
|
22
|
+
cursor: default;
|
|
23
|
+
`;
|
|
24
|
+
export const listTitleStyles = css`
|
|
25
|
+
${typography.h100()}
|
|
26
|
+
text-transform: uppercase;
|
|
27
|
+
margin-bottom: ${gridSize() / 2}px;
|
|
28
|
+
`;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { useCallback, useRef, Fragment } from 'react';
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
3
6
|
import { ErrorMessage, Field } from '@atlaskit/form';
|
|
4
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
8
|
import Textfield from '@atlaskit/textfield';
|
|
6
9
|
import Selectclear from '@atlaskit/icon/glyph/select-clear';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
10
|
+
import { isRedoEvent, isUndoEvent } from '../../utils';
|
|
11
|
+
import { clearTextButtonStyles, fieldStyles } from './styled';
|
|
9
12
|
|
|
10
13
|
const PanelTextInput = props => {
|
|
11
14
|
const {
|
|
@@ -63,28 +66,31 @@ const PanelTextInput = props => {
|
|
|
63
66
|
onClear();
|
|
64
67
|
}
|
|
65
68
|
}, [onClear]);
|
|
66
|
-
const clearText = restProps.value !== '' &&
|
|
69
|
+
const clearText = restProps.value !== '' && jsx(Tooltip, {
|
|
67
70
|
content: clearLabel
|
|
68
|
-
},
|
|
71
|
+
}, jsx("button", {
|
|
72
|
+
css: clearTextButtonStyles,
|
|
69
73
|
onClick: handleClear,
|
|
70
74
|
"data-testid": "clear-text"
|
|
71
|
-
},
|
|
75
|
+
}, jsx(Selectclear, {
|
|
72
76
|
size: "medium",
|
|
73
77
|
label: clearLabel || ''
|
|
74
78
|
})));
|
|
75
|
-
return
|
|
79
|
+
return jsx("div", {
|
|
80
|
+
css: fieldStyles
|
|
81
|
+
}, jsx(Field, {
|
|
76
82
|
label: label,
|
|
77
83
|
name: name
|
|
78
84
|
}, ({
|
|
79
85
|
fieldProps
|
|
80
86
|
}) => {
|
|
81
|
-
return
|
|
87
|
+
return jsx(Fragment, null, jsx(Textfield, _extends({}, fieldProps, restProps, {
|
|
82
88
|
onKeyDown: handleKeydown,
|
|
83
89
|
onChange: handleChange,
|
|
84
90
|
ref: handleRef,
|
|
85
91
|
elemAfterInput: clearText,
|
|
86
92
|
isInvalid: !!error
|
|
87
|
-
})), error &&
|
|
93
|
+
})), error && jsx(ErrorMessage, {
|
|
88
94
|
testId: "link-error"
|
|
89
95
|
}, error));
|
|
90
96
|
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { token } from '@atlaskit/tokens';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { N500 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
5
|
+
export const clearTextButtonStyles = css`
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin-right: ${gridSize() / 2}px;
|
|
8
|
+
color: ${token('color.icon.subtle', N500)};
|
|
9
|
+
background: transparent;
|
|
10
|
+
border: none;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
`;
|
|
13
|
+
export const fieldStyles = css`
|
|
14
|
+
margin-bottom: ${gridSize() * 2}px;
|
|
15
|
+
`;
|
package/dist/es2019/utils.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { browser } from './browser';
|
|
2
|
-
export const relativeFontSizeToBase16 = px => {
|
|
3
|
-
if (typeof px === 'string') {
|
|
4
|
-
px = parseInt(px);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (isNaN(px)) {
|
|
8
|
-
throw new Error(`Invalid font size: '${px}'`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return `${px / 16}rem`;
|
|
12
|
-
};
|
|
13
2
|
const KeyZCode = 90;
|
|
14
3
|
const KeyYCode = 89;
|
|
15
4
|
export const isUndoEvent = e => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -18,13 +18,13 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
18
18
|
|
|
19
19
|
/** @jsx jsx */
|
|
20
20
|
import React, { PureComponent } from 'react';
|
|
21
|
-
import { jsx } from '@emotion/
|
|
21
|
+
import { jsx } from '@emotion/react';
|
|
22
22
|
import { injectIntl } from 'react-intl-next';
|
|
23
23
|
import { messages } from '../messages';
|
|
24
|
-
import PanelTextInput from './
|
|
25
|
-
import LinkSearchList from './
|
|
24
|
+
import PanelTextInput from './text-input';
|
|
25
|
+
import LinkSearchList from './link-search-list';
|
|
26
26
|
import { normalizeUrl, isSafeUrl } from '../url';
|
|
27
|
-
import { recentListStyles,
|
|
27
|
+
import { recentListStyles, containerStyles, searchIconStyles, listTitleStyles } from './styled';
|
|
28
28
|
import { browser } from '../browser';
|
|
29
29
|
import { transformTimeStamp } from '../transformTimeStamp';
|
|
30
30
|
import Announcer from './announcer';
|
|
@@ -335,7 +335,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
335
335
|
key: "updateResults",
|
|
336
336
|
value: function () {
|
|
337
337
|
var _updateResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
338
|
-
var queryVersion, activePlugin, updates,
|
|
338
|
+
var queryVersion, activePlugin, updates, done, value, _result$done, result;
|
|
339
339
|
|
|
340
340
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
341
341
|
while (1) {
|
|
@@ -363,59 +363,78 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
363
363
|
|
|
364
364
|
case 7:
|
|
365
365
|
if (!(queryVersion === this.queryVersion)) {
|
|
366
|
-
_context2.next =
|
|
366
|
+
_context2.next = 29;
|
|
367
367
|
break;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
done = false;
|
|
371
|
+
value = void 0;
|
|
372
|
+
|
|
373
|
+
if (!(updates instanceof Promise)) {
|
|
374
|
+
_context2.next = 17;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
done = true;
|
|
379
|
+
_context2.next = 14;
|
|
380
|
+
return updates;
|
|
381
|
+
|
|
382
|
+
case 14:
|
|
383
|
+
value = _context2.sent;
|
|
384
|
+
_context2.next = 22;
|
|
385
|
+
break;
|
|
386
|
+
|
|
387
|
+
case 17:
|
|
388
|
+
_context2.next = 19;
|
|
371
389
|
return updates.next();
|
|
372
390
|
|
|
373
|
-
case
|
|
374
|
-
|
|
375
|
-
done =
|
|
376
|
-
value =
|
|
391
|
+
case 19:
|
|
392
|
+
result = _context2.sent;
|
|
393
|
+
done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
|
|
394
|
+
value = result.value;
|
|
377
395
|
|
|
396
|
+
case 22:
|
|
378
397
|
if (!(queryVersion !== this.queryVersion)) {
|
|
379
|
-
_context2.next =
|
|
398
|
+
_context2.next = 24;
|
|
380
399
|
break;
|
|
381
400
|
}
|
|
382
401
|
|
|
383
402
|
return _context2.abrupt("return");
|
|
384
403
|
|
|
385
|
-
case
|
|
404
|
+
case 24:
|
|
386
405
|
this.setState({
|
|
387
|
-
items: limit(value),
|
|
406
|
+
items: limit(value.data),
|
|
388
407
|
isLoading: !done
|
|
389
408
|
});
|
|
390
409
|
|
|
391
410
|
if (!done) {
|
|
392
|
-
_context2.next =
|
|
411
|
+
_context2.next = 27;
|
|
393
412
|
break;
|
|
394
413
|
}
|
|
395
414
|
|
|
396
415
|
return _context2.abrupt("return");
|
|
397
416
|
|
|
398
|
-
case
|
|
417
|
+
case 27:
|
|
399
418
|
_context2.next = 7;
|
|
400
419
|
break;
|
|
401
420
|
|
|
402
|
-
case
|
|
403
|
-
_context2.next =
|
|
421
|
+
case 29:
|
|
422
|
+
_context2.next = 34;
|
|
404
423
|
break;
|
|
405
424
|
|
|
406
|
-
case
|
|
407
|
-
_context2.prev =
|
|
425
|
+
case 31:
|
|
426
|
+
_context2.prev = 31;
|
|
408
427
|
_context2.t0 = _context2["catch"](6);
|
|
409
428
|
this.setState({
|
|
410
429
|
isLoading: false
|
|
411
430
|
});
|
|
412
431
|
|
|
413
|
-
case
|
|
432
|
+
case 34:
|
|
414
433
|
case "end":
|
|
415
434
|
return _context2.stop();
|
|
416
435
|
}
|
|
417
436
|
}
|
|
418
|
-
}, _callee2, this, [[6,
|
|
437
|
+
}, _callee2, this, [[6, 31]]);
|
|
419
438
|
}));
|
|
420
439
|
|
|
421
440
|
function updateResults() {
|
|
@@ -447,7 +466,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
447
466
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
448
467
|
|
|
449
468
|
var screenReaderText = browser.safari && this.getScreenReaderText();
|
|
450
|
-
var searchIcon = activePlugin && jsx(
|
|
469
|
+
var searchIcon = activePlugin && jsx("span", {
|
|
470
|
+
css: searchIconStyles,
|
|
451
471
|
"data-testid": "link-picker-search-icon"
|
|
452
472
|
}, jsx(EditorSearchIcon, {
|
|
453
473
|
size: "medium",
|
|
@@ -457,8 +477,9 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
457
477
|
"data-testid": "link-picker",
|
|
458
478
|
className: "recent-list",
|
|
459
479
|
css: recentListStyles
|
|
460
|
-
}, jsx(
|
|
461
|
-
|
|
480
|
+
}, jsx("div", {
|
|
481
|
+
css: containerStyles,
|
|
482
|
+
ref: this.wrapperRef
|
|
462
483
|
}, screenReaderText && jsx(Announcer, {
|
|
463
484
|
ariaLive: "assertive",
|
|
464
485
|
text: screenReaderText,
|
|
@@ -502,7 +523,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
502
523
|
onClear: this.handleClearDisplayText,
|
|
503
524
|
clearLabel: formatMessage(messages.clearText)
|
|
504
525
|
}), !!items.length && jsx("div", {
|
|
505
|
-
css:
|
|
526
|
+
css: listTitleStyles,
|
|
506
527
|
id: "link-picker-list-title",
|
|
507
528
|
"data-testid": "link-picker-list-title"
|
|
508
529
|
}, formatMessage(this.state.url ? messages.titleResults : messages.titleRecentlyViewed)), jsx(VisuallyHidden, null, jsx("span", {
|