@atlaskit/link-picker 0.9.0 → 0.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 +6 -0
- package/dist/cjs/ui/link-picker.js +23 -21
- 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 +10 -8
- 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 +10 -8
- 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/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/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
|
@@ -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';
|
|
@@ -447,7 +447,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
447
447
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
448
448
|
|
|
449
449
|
var screenReaderText = browser.safari && this.getScreenReaderText();
|
|
450
|
-
var searchIcon = activePlugin && jsx(
|
|
450
|
+
var searchIcon = activePlugin && jsx("span", {
|
|
451
|
+
css: searchIconStyles,
|
|
451
452
|
"data-testid": "link-picker-search-icon"
|
|
452
453
|
}, jsx(EditorSearchIcon, {
|
|
453
454
|
size: "medium",
|
|
@@ -457,8 +458,9 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
457
458
|
"data-testid": "link-picker",
|
|
458
459
|
className: "recent-list",
|
|
459
460
|
css: recentListStyles
|
|
460
|
-
}, jsx(
|
|
461
|
-
|
|
461
|
+
}, jsx("div", {
|
|
462
|
+
css: containerStyles,
|
|
463
|
+
ref: this.wrapperRef
|
|
462
464
|
}, screenReaderText && jsx(Announcer, {
|
|
463
465
|
ariaLive: "assertive",
|
|
464
466
|
text: screenReaderText,
|
|
@@ -502,7 +504,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
502
504
|
onClear: this.handleClearDisplayText,
|
|
503
505
|
clearLabel: formatMessage(messages.clearText)
|
|
504
506
|
}), !!items.length && jsx("div", {
|
|
505
|
-
css:
|
|
507
|
+
css: listTitleStyles,
|
|
506
508
|
id: "link-picker-list-title",
|
|
507
509
|
"data-testid": "link-picker-list-title"
|
|
508
510
|
}, formatMessage(this.state.url ? messages.titleResults : messages.titleRecentlyViewed)), jsx(VisuallyHidden, null, jsx("span", {
|
|
@@ -3,22 +3,17 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
7
|
-
|
|
8
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
9
6
|
|
|
10
7
|
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); }; }
|
|
11
8
|
|
|
12
9
|
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; } }
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
/** @jsx jsx */
|
|
15
12
|
import { PureComponent } from 'react';
|
|
13
|
+
import { jsx } from '@emotion/react';
|
|
16
14
|
import Spinner from '@atlaskit/spinner';
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
var ListContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-top: 0;\n"])));
|
|
20
|
-
var SpinnerContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n text-align: center;\n min-height: 80px;\n margin-top: 30px;\n"])));
|
|
21
|
-
export var List = styled.ul(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 0;\n list-style: none;\n"])));
|
|
15
|
+
import LinkSearchListItem from '../list-item';
|
|
16
|
+
import { listContainerStyles, spinnerContainerStyles, listStyles } from './styled';
|
|
22
17
|
|
|
23
18
|
var LinkSearchList = /*#__PURE__*/function (_PureComponent) {
|
|
24
19
|
_inherits(LinkSearchList, _PureComponent);
|
|
@@ -50,13 +45,15 @@ var LinkSearchList = /*#__PURE__*/function (_PureComponent) {
|
|
|
50
45
|
var loadingContent;
|
|
51
46
|
|
|
52
47
|
if (items && items.length > 0) {
|
|
53
|
-
itemsContent =
|
|
48
|
+
itemsContent = jsx("ul", {
|
|
49
|
+
"data-testid": "link-search-list",
|
|
50
|
+
css: listStyles,
|
|
54
51
|
id: id,
|
|
55
52
|
role: role,
|
|
56
53
|
"aria-controls": ariaControls,
|
|
57
54
|
"aria-labelledby": ariaLabelledBy
|
|
58
55
|
}, items.map(function (item, index) {
|
|
59
|
-
return
|
|
56
|
+
return jsx(LinkSearchListItem, {
|
|
60
57
|
id: "link-search-list-item-".concat(index),
|
|
61
58
|
role: role && 'option',
|
|
62
59
|
item: item,
|
|
@@ -71,13 +68,17 @@ var LinkSearchList = /*#__PURE__*/function (_PureComponent) {
|
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
if (isLoading) {
|
|
74
|
-
loadingContent =
|
|
71
|
+
loadingContent = jsx("div", {
|
|
72
|
+
css: spinnerContainerStyles
|
|
73
|
+
}, jsx(Spinner, {
|
|
75
74
|
testId: "link-picker.results-loading-indicator",
|
|
76
75
|
size: "medium"
|
|
77
76
|
}));
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
return
|
|
79
|
+
return jsx("div", {
|
|
80
|
+
css: listContainerStyles
|
|
81
|
+
}, itemsContent, loadingContent);
|
|
81
82
|
}
|
|
82
83
|
}]);
|
|
83
84
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
|
|
5
|
+
import { css } from '@emotion/react';
|
|
6
|
+
export var listContainerStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-top: 0;\n"])));
|
|
7
|
+
export var spinnerContainerStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n text-align: center;\n min-height: 80px;\n margin-top: 30px;\n"])));
|
|
8
|
+
export var listStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 0;\n list-style: none;\n"])));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
|
-
import { transformTimeStamp } from '
|
|
6
|
-
import {
|
|
5
|
+
import { transformTimeStamp } from '../../transformTimeStamp';
|
|
6
|
+
import { itemNameStyles, itemIconStyles, listItemContextStyles, listItemNameStyles, composeListItemStyles, imgStyles } from './styled';
|
|
7
7
|
|
|
8
8
|
var LinkSearchListItem = function LinkSearchListItem(_ref) {
|
|
9
9
|
var item = _ref.item,
|
|
@@ -28,37 +28,35 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
|
|
|
28
28
|
return onMouseLeave(item.objectId);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
var container = item.container || null;
|
|
32
|
+
var date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
|
|
33
|
+
return jsx("div", {
|
|
34
|
+
css: composeListItemStyles(active, selected),
|
|
32
35
|
role: role,
|
|
33
36
|
id: id,
|
|
34
37
|
"aria-selected": selected,
|
|
35
38
|
"data-testid": "link-search-list-item",
|
|
36
|
-
selected: selected,
|
|
37
|
-
active: active,
|
|
38
39
|
onMouseEnter: handleMouseEnter,
|
|
39
40
|
onMouseLeave: handleMouseLeave,
|
|
40
41
|
onClick: handleSelect
|
|
41
42
|
}, jsx(ListItemIcon, {
|
|
42
43
|
item: item,
|
|
43
44
|
intl: intl
|
|
44
|
-
}), jsx(
|
|
45
|
-
|
|
46
|
-
}
|
|
45
|
+
}), jsx("div", {
|
|
46
|
+
css: itemNameStyles
|
|
47
|
+
}, jsx("div", {
|
|
48
|
+
"data-testid": "link-search-list-item-title",
|
|
49
|
+
css: listItemNameStyles
|
|
50
|
+
}, item.name), jsx("div", {
|
|
51
|
+
"data-testid": "link-search-list-item-subtitle",
|
|
52
|
+
css: listItemContextStyles
|
|
53
|
+
}, container, container && date && jsx(Fragment, null, "\xA0 \u2022\xA0 "), date && jsx(Fragment, null, formatDate(date)))));
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
export default injectIntl(LinkSearchListItem);
|
|
50
57
|
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!date) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return jsx(Fragment, null, jsx("span", {
|
|
59
|
-
className: "link-search-timestamp",
|
|
60
|
-
"data-test-id": "link-search-timestamp"
|
|
61
|
-
}, "\xA0 ", date.pageAction, " ", date.dateString, " ", date.timeSince || ''));
|
|
58
|
+
var formatDate = function formatDate(date) {
|
|
59
|
+
return [date.pageAction, date.dateString, date.timeSince].filter(Boolean).join(' ');
|
|
62
60
|
};
|
|
63
61
|
|
|
64
62
|
var ListItemIcon = function ListItemIcon(props) {
|
|
@@ -75,14 +73,18 @@ var ListItemIcon = function ListItemIcon(props) {
|
|
|
75
73
|
|
|
76
74
|
if (typeof icon !== 'string') {
|
|
77
75
|
var Glyph = icon;
|
|
78
|
-
return jsx(
|
|
76
|
+
return jsx("span", {
|
|
77
|
+
css: itemIconStyles
|
|
78
|
+
}, jsx(Glyph, {
|
|
79
79
|
alt: alt
|
|
80
80
|
}));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
return jsx(
|
|
83
|
+
return jsx("span", {
|
|
84
|
+
css: itemIconStyles
|
|
85
|
+
}, jsx("img", {
|
|
84
86
|
src: icon,
|
|
85
87
|
alt: alt,
|
|
86
|
-
css:
|
|
88
|
+
css: imgStyles
|
|
87
89
|
}));
|
|
88
90
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
4
|
+
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { css } from '@emotion/react';
|
|
7
|
+
import { B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { gridSize } from '@atlaskit/theme/constants'; // AFP-2532 TODO: Fix automatic suppressions below
|
|
9
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
10
|
+
|
|
11
|
+
import { fontSizeSmall, fontSize } from '@atlaskit/theme';
|
|
12
|
+
export var relativeFontSizeToBase16 = function relativeFontSizeToBase16(px) {
|
|
13
|
+
if (typeof px === 'string') {
|
|
14
|
+
px = parseInt(px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (isNaN(px)) {
|
|
18
|
+
throw new Error("Invalid font size: '".concat(px, "'"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return "".concat(px / 16, "rem");
|
|
22
|
+
};
|
|
23
|
+
var listItemBaseStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n padding: ", "px ", "px;\n margin: 0 -", "px;\n cursor: pointer;\n"])), gridSize(), gridSize() * 2, gridSize() * 2);
|
|
24
|
+
var listItemBoxShadow = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-shadow: inset 2px 0px 0px ", ";\n"])), token('color.border.selected', B400));
|
|
25
|
+
var listItemActive = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background-color: ", ";\n"])), token('color.background.neutral.subtle.hovered', N20));
|
|
26
|
+
var listItemSelected = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: ", ";\n"])), token('color.background.selected', B50));
|
|
27
|
+
export var composeListItemStyles = function composeListItemStyles() {
|
|
28
|
+
var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
29
|
+
var selected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
30
|
+
var hasShadow = active || selected;
|
|
31
|
+
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", ";\n ", ";\n "])), listItemBaseStyles, active && listItemActive, selected && listItemSelected, hasShadow && listItemBoxShadow);
|
|
32
|
+
};
|
|
33
|
+
export var itemNameStyles = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n"])));
|
|
34
|
+
export var listItemNameStyles = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n color: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 20px;\n"])), token('color.text', N800));
|
|
35
|
+
export var listItemContextStyles = css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n line-height: ", "px;\n"])), token('color.text', N300), relativeFontSizeToBase16(fontSizeSmall()), fontSize());
|
|
36
|
+
export var itemIconStyles = css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n min-width: ", "px;\n margin-top: 3px;\n margin-right: 12px;\n"])), gridSize() * 2);
|
|
37
|
+
export var imgStyles = css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n max-width: ", "px;\n"])), gridSize() * 2);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
|
+
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { css } from '@emotion/react';
|
|
7
|
+
import { N500 } from '@atlaskit/theme/colors'; // AFP-2532 TODO: Fix automatic suppressions below
|
|
8
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
9
|
+
|
|
10
|
+
import { typography } from '@atlaskit/theme';
|
|
11
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
12
|
+
var LINK_PICKER_WIDTH_IN_PX = 342;
|
|
13
|
+
export var recentListStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX);
|
|
14
|
+
export var containerStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: ", "px;\n width: 100%;\n overflow: hidden;\n line-height: initial;\n box-sizing: border-box;\n"])), gridSize() * 2);
|
|
15
|
+
export var searchIconStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: ", "px;\n color: ", ";\n cursor: default;\n"])), gridSize() / 2, token('color.icon', N500));
|
|
16
|
+
export var listTitleStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n text-transform: uppercase;\n margin-bottom: ", "px;\n"])), typography.h100(), gridSize() / 2);
|