@atlaskit/link-picker 0.8.1 → 0.11.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 +62 -40
- 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 +26 -14
- 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 +49 -27
- 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 +6 -3
- 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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.fieldStyles = exports.clearTextButtonStyles = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _tokens = require("@atlaskit/tokens");
|
|
13
|
+
|
|
14
|
+
var _react = require("@emotion/react");
|
|
15
|
+
|
|
16
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
+
|
|
18
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2;
|
|
21
|
+
|
|
22
|
+
var clearTextButtonStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 0;\n margin-right: ", "px;\n color: ", ";\n background: transparent;\n border: none;\n cursor: pointer;\n"])), (0, _constants.gridSize)() / 2, (0, _tokens.token)('color.icon.subtle', _colors.N500));
|
|
23
|
+
exports.clearTextButtonStyles = clearTextButtonStyles;
|
|
24
|
+
var fieldStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-bottom: ", "px;\n"])), (0, _constants.gridSize)() * 2);
|
|
25
|
+
exports.fieldStyles = fieldStyles;
|
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';
|
|
@@ -84,7 +84,8 @@ class LinkPicker extends PureComponent {
|
|
|
84
84
|
lastViewedDate
|
|
85
85
|
} = items[selectedIndex];
|
|
86
86
|
const date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
|
|
87
|
-
|
|
87
|
+
const 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(' ');
|
|
88
|
+
return [name, container, formattedDate].filter(Boolean).join(', ');
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
|
|
@@ -318,17 +319,26 @@ class LinkPicker extends PureComponent {
|
|
|
318
319
|
|
|
319
320
|
try {
|
|
320
321
|
while (queryVersion === this.queryVersion) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
+
}
|
|
325
335
|
|
|
326
336
|
if (queryVersion !== this.queryVersion) {
|
|
327
337
|
return;
|
|
328
338
|
}
|
|
329
339
|
|
|
330
340
|
this.setState({
|
|
331
|
-
items: limit(value),
|
|
341
|
+
items: limit(value.data),
|
|
332
342
|
isLoading: !done
|
|
333
343
|
});
|
|
334
344
|
|
|
@@ -369,7 +379,8 @@ class LinkPicker extends PureComponent {
|
|
|
369
379
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
370
380
|
|
|
371
381
|
const screenReaderText = browser.safari && this.getScreenReaderText();
|
|
372
|
-
const searchIcon = activePlugin && jsx(
|
|
382
|
+
const searchIcon = activePlugin && jsx("span", {
|
|
383
|
+
css: searchIconStyles,
|
|
373
384
|
"data-testid": "link-picker-search-icon"
|
|
374
385
|
}, jsx(EditorSearchIcon, {
|
|
375
386
|
size: "medium",
|
|
@@ -379,8 +390,9 @@ class LinkPicker extends PureComponent {
|
|
|
379
390
|
"data-testid": "link-picker",
|
|
380
391
|
className: "recent-list",
|
|
381
392
|
css: recentListStyles
|
|
382
|
-
}, jsx(
|
|
383
|
-
|
|
393
|
+
}, jsx("div", {
|
|
394
|
+
css: containerStyles,
|
|
395
|
+
ref: this.wrapperRef
|
|
384
396
|
}, screenReaderText && jsx(Announcer, {
|
|
385
397
|
ariaLive: "assertive",
|
|
386
398
|
text: screenReaderText,
|
|
@@ -424,7 +436,7 @@ class LinkPicker extends PureComponent {
|
|
|
424
436
|
onClear: this.handleClearDisplayText,
|
|
425
437
|
clearLabel: formatMessage(messages.clearText)
|
|
426
438
|
}), !!items.length && jsx("div", {
|
|
427
|
-
css:
|
|
439
|
+
css: listTitleStyles,
|
|
428
440
|
id: "link-picker-list-title",
|
|
429
441
|
"data-testid": "link-picker-list-title"
|
|
430
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';
|
|
@@ -123,7 +123,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
123
123
|
lastUpdatedDate = _items$selectedIndex.lastUpdatedDate,
|
|
124
124
|
lastViewedDate = _items$selectedIndex.lastViewedDate;
|
|
125
125
|
var date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
|
|
126
|
-
|
|
126
|
+
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(' ');
|
|
127
|
+
return [name, container, formattedDate].filter(Boolean).join(', ');
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
130
|
|
|
@@ -334,7 +335,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
334
335
|
key: "updateResults",
|
|
335
336
|
value: function () {
|
|
336
337
|
var _updateResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
337
|
-
var queryVersion, activePlugin, updates,
|
|
338
|
+
var queryVersion, activePlugin, updates, done, value, _result$done, result;
|
|
338
339
|
|
|
339
340
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
340
341
|
while (1) {
|
|
@@ -362,59 +363,78 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
362
363
|
|
|
363
364
|
case 7:
|
|
364
365
|
if (!(queryVersion === this.queryVersion)) {
|
|
365
|
-
_context2.next =
|
|
366
|
+
_context2.next = 29;
|
|
366
367
|
break;
|
|
367
368
|
}
|
|
368
369
|
|
|
369
|
-
|
|
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;
|
|
370
389
|
return updates.next();
|
|
371
390
|
|
|
372
|
-
case
|
|
373
|
-
|
|
374
|
-
done =
|
|
375
|
-
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;
|
|
376
395
|
|
|
396
|
+
case 22:
|
|
377
397
|
if (!(queryVersion !== this.queryVersion)) {
|
|
378
|
-
_context2.next =
|
|
398
|
+
_context2.next = 24;
|
|
379
399
|
break;
|
|
380
400
|
}
|
|
381
401
|
|
|
382
402
|
return _context2.abrupt("return");
|
|
383
403
|
|
|
384
|
-
case
|
|
404
|
+
case 24:
|
|
385
405
|
this.setState({
|
|
386
|
-
items: limit(value),
|
|
406
|
+
items: limit(value.data),
|
|
387
407
|
isLoading: !done
|
|
388
408
|
});
|
|
389
409
|
|
|
390
410
|
if (!done) {
|
|
391
|
-
_context2.next =
|
|
411
|
+
_context2.next = 27;
|
|
392
412
|
break;
|
|
393
413
|
}
|
|
394
414
|
|
|
395
415
|
return _context2.abrupt("return");
|
|
396
416
|
|
|
397
|
-
case
|
|
417
|
+
case 27:
|
|
398
418
|
_context2.next = 7;
|
|
399
419
|
break;
|
|
400
420
|
|
|
401
|
-
case
|
|
402
|
-
_context2.next =
|
|
421
|
+
case 29:
|
|
422
|
+
_context2.next = 34;
|
|
403
423
|
break;
|
|
404
424
|
|
|
405
|
-
case
|
|
406
|
-
_context2.prev =
|
|
425
|
+
case 31:
|
|
426
|
+
_context2.prev = 31;
|
|
407
427
|
_context2.t0 = _context2["catch"](6);
|
|
408
428
|
this.setState({
|
|
409
429
|
isLoading: false
|
|
410
430
|
});
|
|
411
431
|
|
|
412
|
-
case
|
|
432
|
+
case 34:
|
|
413
433
|
case "end":
|
|
414
434
|
return _context2.stop();
|
|
415
435
|
}
|
|
416
436
|
}
|
|
417
|
-
}, _callee2, this, [[6,
|
|
437
|
+
}, _callee2, this, [[6, 31]]);
|
|
418
438
|
}));
|
|
419
439
|
|
|
420
440
|
function updateResults() {
|
|
@@ -446,7 +466,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
446
466
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
447
467
|
|
|
448
468
|
var screenReaderText = browser.safari && this.getScreenReaderText();
|
|
449
|
-
var searchIcon = activePlugin && jsx(
|
|
469
|
+
var searchIcon = activePlugin && jsx("span", {
|
|
470
|
+
css: searchIconStyles,
|
|
450
471
|
"data-testid": "link-picker-search-icon"
|
|
451
472
|
}, jsx(EditorSearchIcon, {
|
|
452
473
|
size: "medium",
|
|
@@ -456,8 +477,9 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
456
477
|
"data-testid": "link-picker",
|
|
457
478
|
className: "recent-list",
|
|
458
479
|
css: recentListStyles
|
|
459
|
-
}, jsx(
|
|
460
|
-
|
|
480
|
+
}, jsx("div", {
|
|
481
|
+
css: containerStyles,
|
|
482
|
+
ref: this.wrapperRef
|
|
461
483
|
}, screenReaderText && jsx(Announcer, {
|
|
462
484
|
ariaLive: "assertive",
|
|
463
485
|
text: screenReaderText,
|
|
@@ -501,7 +523,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
501
523
|
onClear: this.handleClearDisplayText,
|
|
502
524
|
clearLabel: formatMessage(messages.clearText)
|
|
503
525
|
}), !!items.length && jsx("div", {
|
|
504
|
-
css:
|
|
526
|
+
css: listTitleStyles,
|
|
505
527
|
id: "link-picker-list-title",
|
|
506
528
|
"data-testid": "link-picker-list-title"
|
|
507
529
|
}, formatMessage(this.state.url ? messages.titleResults : messages.titleRecentlyViewed)), jsx(VisuallyHidden, null, jsx("span", {
|