@atlaskit/quick-search 8.0.9
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 +763 -0
- package/LICENSE +13 -0
- package/build/tsconfig.json +17 -0
- package/dist/cjs/components/QuickSearch.js +447 -0
- package/dist/cjs/components/ResultItem/ResultItem.js +87 -0
- package/dist/cjs/components/ResultItem/ResultItemGroup.js +57 -0
- package/dist/cjs/components/ResultItem/styled.js +53 -0
- package/dist/cjs/components/Results/ContainerResult.js +93 -0
- package/dist/cjs/components/Results/ObjectResult.js +108 -0
- package/dist/cjs/components/Results/PersonResult.js +99 -0
- package/dist/cjs/components/Results/ResultBase.js +206 -0
- package/dist/cjs/components/Results/index.js +39 -0
- package/dist/cjs/components/Results/types.js +5 -0
- package/dist/cjs/components/Search/Search.js +124 -0
- package/dist/cjs/components/Search/styled.js +61 -0
- package/dist/cjs/components/constants.js +20 -0
- package/dist/cjs/components/context.js +29 -0
- package/dist/cjs/components/decorateWithAnalyticsData.js +80 -0
- package/dist/cjs/components/isReactElement.js +19 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/version.json +4 -0
- package/dist/es2019/components/QuickSearch.js +417 -0
- package/dist/es2019/components/ResultItem/ResultItem.js +41 -0
- package/dist/es2019/components/ResultItem/ResultItemGroup.js +16 -0
- package/dist/es2019/components/ResultItem/styled.js +54 -0
- package/dist/es2019/components/Results/ContainerResult.js +45 -0
- package/dist/es2019/components/Results/ObjectResult.js +60 -0
- package/dist/es2019/components/Results/PersonResult.js +50 -0
- package/dist/es2019/components/Results/ResultBase.js +149 -0
- package/dist/es2019/components/Results/index.js +4 -0
- package/dist/es2019/components/Results/types.js +1 -0
- package/dist/es2019/components/Search/Search.js +80 -0
- package/dist/es2019/components/Search/styled.js +76 -0
- package/dist/es2019/components/constants.js +7 -0
- package/dist/es2019/components/context.js +11 -0
- package/dist/es2019/components/decorateWithAnalyticsData.js +33 -0
- package/dist/es2019/components/isReactElement.js +10 -0
- package/dist/es2019/index.js +23 -0
- package/dist/es2019/version.json +4 -0
- package/dist/esm/components/QuickSearch.js +442 -0
- package/dist/esm/components/ResultItem/ResultItem.js +65 -0
- package/dist/esm/components/ResultItem/ResultItemGroup.js +42 -0
- package/dist/esm/components/ResultItem/styled.js +18 -0
- package/dist/esm/components/Results/ContainerResult.js +78 -0
- package/dist/esm/components/Results/ObjectResult.js +93 -0
- package/dist/esm/components/Results/PersonResult.js +86 -0
- package/dist/esm/components/Results/ResultBase.js +189 -0
- package/dist/esm/components/Results/index.js +4 -0
- package/dist/esm/components/Results/types.js +1 -0
- package/dist/esm/components/Search/Search.js +108 -0
- package/dist/esm/components/Search/styled.js +20 -0
- package/dist/esm/components/constants.js +7 -0
- package/dist/esm/components/context.js +13 -0
- package/dist/esm/components/decorateWithAnalyticsData.js +64 -0
- package/dist/esm/components/isReactElement.js +10 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/version.json +4 -0
- package/dist/types/components/QuickSearch.d.ts +122 -0
- package/dist/types/components/ResultItem/ResultItem.d.ts +38 -0
- package/dist/types/components/ResultItem/ResultItemGroup.d.ts +11 -0
- package/dist/types/components/ResultItem/styled.d.ts +13 -0
- package/dist/types/components/Results/ContainerResult.d.ts +19 -0
- package/dist/types/components/Results/ObjectResult.d.ts +22 -0
- package/dist/types/components/Results/PersonResult.d.ts +20 -0
- package/dist/types/components/Results/ResultBase.d.ts +37 -0
- package/dist/types/components/Results/index.d.ts +4 -0
- package/dist/types/components/Results/types.d.ts +34 -0
- package/dist/types/components/Search/Search.d.ts +31 -0
- package/dist/types/components/Search/styled.d.ts +10 -0
- package/dist/types/components/constants.d.ts +6 -0
- package/dist/types/components/context.d.ts +22 -0
- package/dist/types/components/decorateWithAnalyticsData.d.ts +3 -0
- package/dist/types/components/isReactElement.d.ts +6 -0
- package/dist/types/index.d.ts +17 -0
- package/docs/0-intro.tsx +53 -0
- package/package.json +52 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import baseItem, { withItemClick, withItemFocus } from '@atlaskit/item';
|
|
5
|
+
import { ResultItemAfter, ResultItemAfterWrapper, ResultItemCaption, ResultItemIcon, ResultItemTextAfter, ResultItemSubText } from './styled';
|
|
6
|
+
const Item = withItemClick(withItemFocus(baseItem));
|
|
7
|
+
|
|
8
|
+
class ResultItem extends React.PureComponent {
|
|
9
|
+
render() {
|
|
10
|
+
const icon = this.props.icon ? /*#__PURE__*/React.createElement(ResultItemIcon, null, this.props.icon) : null;
|
|
11
|
+
const textAfter = this.props.textAfter ? /*#__PURE__*/React.createElement(ResultItemTextAfter, null, this.props.textAfter) : null;
|
|
12
|
+
const after = this.props.textAfter || this.props.selectedIcon ? /*#__PURE__*/React.createElement(ResultItemAfterWrapper, null, /*#__PURE__*/React.createElement(ResultItemAfter, {
|
|
13
|
+
shouldTakeSpace: !!this.props.textAfter
|
|
14
|
+
}, textAfter, this.props.isSelected && !this.props.isMouseSelected ? this.props.selectedIcon : null)) : null;
|
|
15
|
+
const wrappedCaption = this.props.caption ? /*#__PURE__*/React.createElement(ResultItemCaption, null, this.props.caption) : null;
|
|
16
|
+
const wrappedSubText = this.props.subText ? /*#__PURE__*/React.createElement(ResultItemSubText, null, this.props.subText) : null;
|
|
17
|
+
const interactiveWrapperProps = {
|
|
18
|
+
onClick: this.props.onClick,
|
|
19
|
+
onMouseEnter: this.props.onMouseEnter,
|
|
20
|
+
onMouseLeave: this.props.onMouseLeave,
|
|
21
|
+
href: this.props.href
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/React.createElement(Item, _extends({
|
|
24
|
+
elemBefore: icon,
|
|
25
|
+
elemAfter: after,
|
|
26
|
+
description: wrappedSubText,
|
|
27
|
+
isSelected: this.props.isSelected,
|
|
28
|
+
isCompact: this.props.isCompact,
|
|
29
|
+
target: this.props.target,
|
|
30
|
+
linkComponent: this.props.linkComponent
|
|
31
|
+
}, interactiveWrapperProps), this.props.text, wrappedCaption);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_defineProperty(ResultItem, "defaultProps", {
|
|
37
|
+
isSelected: false,
|
|
38
|
+
isMouseSelected: false
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export default ResultItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ItemGroup } from '@atlaskit/item';
|
|
3
|
+
import { ResultItemGroupTitle, ResultItemGroupHeader } from './styled';
|
|
4
|
+
export default class ResultItemGroup extends React.Component {
|
|
5
|
+
render() {
|
|
6
|
+
const {
|
|
7
|
+
title,
|
|
8
|
+
children
|
|
9
|
+
} = this.props;
|
|
10
|
+
const wrappedTitle = /*#__PURE__*/React.createElement(ResultItemGroupHeader, null, /*#__PURE__*/React.createElement(ResultItemGroupTitle, null, title));
|
|
11
|
+
return /*#__PURE__*/React.createElement(ItemGroup, {
|
|
12
|
+
title: wrappedTitle
|
|
13
|
+
}, children);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
+
import { N200 } from '@atlaskit/theme/colors';
|
|
4
|
+
export const ResultItemGroupHeader = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
margin-left: -${gridSize() * 1.5}px;
|
|
7
|
+
margin-top: ${gridSize() * 1.5}px;
|
|
8
|
+
`;
|
|
9
|
+
export const ResultItemGroupTitle = styled.div`
|
|
10
|
+
font-size: 11px;
|
|
11
|
+
line-height: ${gridSize() * 2}px;
|
|
12
|
+
font-weight: 600;
|
|
13
|
+
`;
|
|
14
|
+
export const ResultItemAfter = styled.div`
|
|
15
|
+
min-width: ${({
|
|
16
|
+
shouldTakeSpace
|
|
17
|
+
}) => shouldTakeSpace ? '24px' : 0};
|
|
18
|
+
`;
|
|
19
|
+
export const ResultItemAfterWrapper = styled.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
`;
|
|
22
|
+
export const ResultItemCaption = styled.span`
|
|
23
|
+
color: ${N200};
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
margin-left: ${gridSize()}px;
|
|
26
|
+
`;
|
|
27
|
+
export const ResultItemSubText = styled.span`
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
color: ${N200};
|
|
30
|
+
`;
|
|
31
|
+
export const ResultItemIcon = styled.div`
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
transition: padding 200ms;
|
|
37
|
+
|
|
38
|
+
> * {
|
|
39
|
+
flex: 1 0 auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* We need to ensure that any image passed in as a child (<img/>, <svg/>
|
|
43
|
+
etc.) receives the correct width, height and border radius. We don't
|
|
44
|
+
currently assume that the image passed in is the correct dimensions, or has
|
|
45
|
+
width / height 100% */
|
|
46
|
+
> img {
|
|
47
|
+
height: ${gridSize() * 3}px;
|
|
48
|
+
width: ${gridSize() * 3}px;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
export const ResultItemTextAfter = styled.div`
|
|
52
|
+
position: relative;
|
|
53
|
+
z-index: 1;
|
|
54
|
+
`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from '@atlaskit/avatar';
|
|
5
|
+
import ResultBase from './ResultBase';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generic result type for Atlassian containers.
|
|
9
|
+
*/
|
|
10
|
+
export default class ContainerResult extends React.PureComponent {
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "getAvatar", () => {
|
|
15
|
+
if (this.props.avatar) {
|
|
16
|
+
return this.props.avatar;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
20
|
+
borderColor: "transparent",
|
|
21
|
+
src: this.props.avatarUrl,
|
|
22
|
+
appearance: "square",
|
|
23
|
+
size: "small",
|
|
24
|
+
status: this.props.isPrivate ? 'locked' : null
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
const {
|
|
31
|
+
name,
|
|
32
|
+
isPrivate,
|
|
33
|
+
type = 'container',
|
|
34
|
+
subText,
|
|
35
|
+
...commonResultProps
|
|
36
|
+
} = this.props;
|
|
37
|
+
return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
|
|
38
|
+
type: type,
|
|
39
|
+
text: name,
|
|
40
|
+
subText: subText,
|
|
41
|
+
icon: this.getAvatar()
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from '@atlaskit/avatar';
|
|
5
|
+
import ResultBase from './ResultBase';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generic result type for Atlassian objects.
|
|
9
|
+
*/
|
|
10
|
+
export default class ObjectResult extends React.PureComponent {
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "getAvatar", () => {
|
|
15
|
+
if (this.props.avatar) {
|
|
16
|
+
return this.props.avatar;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
20
|
+
borderColor: "transparent",
|
|
21
|
+
src: this.props.avatarUrl,
|
|
22
|
+
appearance: "square",
|
|
23
|
+
size: "small",
|
|
24
|
+
status: this.props.isPrivate ? 'locked' : null,
|
|
25
|
+
testId: "object-result"
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getSubtext() {
|
|
31
|
+
const {
|
|
32
|
+
objectKey,
|
|
33
|
+
containerName
|
|
34
|
+
} = this.props;
|
|
35
|
+
|
|
36
|
+
if (objectKey && containerName) {
|
|
37
|
+
return /*#__PURE__*/React.createElement("span", null, objectKey, " \xB7 ", containerName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return containerName || objectKey;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
const {
|
|
45
|
+
name,
|
|
46
|
+
containerName,
|
|
47
|
+
isPrivate,
|
|
48
|
+
objectKey,
|
|
49
|
+
type = 'object',
|
|
50
|
+
...commonResultProps
|
|
51
|
+
} = this.props;
|
|
52
|
+
return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
|
|
53
|
+
type: type,
|
|
54
|
+
text: name,
|
|
55
|
+
subText: this.getSubtext(),
|
|
56
|
+
icon: this.getAvatar()
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from '@atlaskit/avatar';
|
|
5
|
+
import ResultBase from './ResultBase';
|
|
6
|
+
export default class PersonResult extends React.PureComponent {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "getMention", () => this.props.mentionName ? `${this.props.mentionPrefix}${this.props.mentionName}` : undefined);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "getAvatar", () => {
|
|
13
|
+
if (this.props.avatar) {
|
|
14
|
+
return this.props.avatar;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
18
|
+
presence: this.props.presenceState,
|
|
19
|
+
size: "small",
|
|
20
|
+
src: this.props.avatarUrl
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
const {
|
|
27
|
+
name,
|
|
28
|
+
mentionName,
|
|
29
|
+
mentionPrefix,
|
|
30
|
+
presenceMessage,
|
|
31
|
+
presenceState,
|
|
32
|
+
type = 'person',
|
|
33
|
+
...commonResultProps
|
|
34
|
+
} = this.props;
|
|
35
|
+
return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
|
|
36
|
+
type: type,
|
|
37
|
+
text: name,
|
|
38
|
+
subText: presenceMessage,
|
|
39
|
+
caption: this.getMention(),
|
|
40
|
+
icon: this.getAvatar()
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_defineProperty(PersonResult, "defaultProps", {
|
|
47
|
+
mentionPrefix: '@',
|
|
48
|
+
presenceState: null // No presence indicator by default
|
|
49
|
+
|
|
50
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { QS_ANALYTICS_EV_SUBMIT } from '../constants';
|
|
5
|
+
import ResultItem from '../ResultItem/ResultItem';
|
|
6
|
+
import { ResultContext, SelectedResultIdContext } from '../context';
|
|
7
|
+
export class ResultBase extends React.PureComponent {
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
super(...args);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "state", {
|
|
12
|
+
isMouseSelected: false
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "handleClick", e => {
|
|
16
|
+
const {
|
|
17
|
+
onClick,
|
|
18
|
+
resultId,
|
|
19
|
+
type,
|
|
20
|
+
context
|
|
21
|
+
} = this.props;
|
|
22
|
+
|
|
23
|
+
if (context.sendAnalytics) {
|
|
24
|
+
context.sendAnalytics(QS_ANALYTICS_EV_SUBMIT, { ...this.getAnalyticsData(),
|
|
25
|
+
method: 'click',
|
|
26
|
+
newTab: e && (e.metaKey || e.shiftKey || e.ctrlKey)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (onClick) {
|
|
31
|
+
onClick({
|
|
32
|
+
resultId,
|
|
33
|
+
type,
|
|
34
|
+
event: e
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "handleMouseEnter", event => {
|
|
40
|
+
this.props.context.onMouseEnter({
|
|
41
|
+
resultId: this.props.resultId,
|
|
42
|
+
type: this.props.type,
|
|
43
|
+
event
|
|
44
|
+
});
|
|
45
|
+
this.setState({
|
|
46
|
+
isMouseSelected: true
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
_defineProperty(this, "handleMouseLeave", () => {
|
|
51
|
+
this.props.context.onMouseLeave();
|
|
52
|
+
this.setState({
|
|
53
|
+
isMouseSelected: false
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
registerResult() {
|
|
59
|
+
const {
|
|
60
|
+
context
|
|
61
|
+
} = this.props;
|
|
62
|
+
context.registerResult(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
this.registerResult();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
componentDidUpdate() {
|
|
70
|
+
this.registerResult();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
componentWillUnmount() {
|
|
74
|
+
const {
|
|
75
|
+
context
|
|
76
|
+
} = this.props;
|
|
77
|
+
context.unregisterResult(this);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getAnalyticsData() {
|
|
81
|
+
const {
|
|
82
|
+
resultId,
|
|
83
|
+
analyticsData,
|
|
84
|
+
type,
|
|
85
|
+
context
|
|
86
|
+
} = this.props;
|
|
87
|
+
return {
|
|
88
|
+
index: context.getIndex(resultId),
|
|
89
|
+
type,
|
|
90
|
+
resultId,
|
|
91
|
+
...(analyticsData instanceof Function ? analyticsData() : analyticsData)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
render() {
|
|
96
|
+
const {
|
|
97
|
+
caption,
|
|
98
|
+
elemAfter,
|
|
99
|
+
selectedIcon,
|
|
100
|
+
href,
|
|
101
|
+
target,
|
|
102
|
+
icon,
|
|
103
|
+
isCompact,
|
|
104
|
+
subText,
|
|
105
|
+
text,
|
|
106
|
+
resultId,
|
|
107
|
+
context
|
|
108
|
+
} = this.props;
|
|
109
|
+
const {
|
|
110
|
+
isMouseSelected
|
|
111
|
+
} = this.state;
|
|
112
|
+
return /*#__PURE__*/React.createElement(SelectedResultIdContext.Consumer, null, selectedResultId => /*#__PURE__*/React.createElement(ResultItem, {
|
|
113
|
+
caption: caption,
|
|
114
|
+
href: href,
|
|
115
|
+
target: target,
|
|
116
|
+
icon: icon,
|
|
117
|
+
isCompact: isCompact,
|
|
118
|
+
isSelected: resultId === selectedResultId,
|
|
119
|
+
onClick: this.handleClick,
|
|
120
|
+
onMouseEnter: this.handleMouseEnter,
|
|
121
|
+
onMouseLeave: this.handleMouseLeave,
|
|
122
|
+
isMouseSelected: isMouseSelected,
|
|
123
|
+
subText: subText,
|
|
124
|
+
text: text,
|
|
125
|
+
textAfter: elemAfter,
|
|
126
|
+
selectedIcon: selectedIcon,
|
|
127
|
+
linkComponent: context.linkComponent
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_defineProperty(ResultBase, "defaultProps", {
|
|
134
|
+
type: 'base',
|
|
135
|
+
context: {
|
|
136
|
+
registerResult: result => {},
|
|
137
|
+
unregisterResult: result => {},
|
|
138
|
+
onMouseEnter: resultData => {},
|
|
139
|
+
onMouseLeave: () => {},
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
sendAnalytics: (string, data) => {},
|
|
142
|
+
getIndex: () => null
|
|
143
|
+
},
|
|
144
|
+
analyticsData: {}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export default (props => /*#__PURE__*/React.createElement(ResultContext.Consumer, null, context => /*#__PURE__*/React.createElement(ResultBase, _extends({
|
|
148
|
+
context: context
|
|
149
|
+
}, props))));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Spinner from '@atlaskit/spinner';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { SearchBox, SearchFieldBaseInner, SearchInner, SearchInput, SearchFieldBaseOuter, SearchInputControlsContainer, SearchInputTypeAhead } from './styled';
|
|
6
|
+
export const controlKeys = ['ArrowUp', 'ArrowDown', 'Enter', 'Tab', 'ArrowRight'];
|
|
7
|
+
const SpinnerParent = styled.div`
|
|
8
|
+
height: 20px;
|
|
9
|
+
margin-left: 10px;
|
|
10
|
+
margin-top: 10px;
|
|
11
|
+
`;
|
|
12
|
+
export default class Search extends React.PureComponent {
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
super(...args);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "onInputKeyDown", event => {
|
|
17
|
+
const {
|
|
18
|
+
onKeyDown
|
|
19
|
+
} = this.props;
|
|
20
|
+
|
|
21
|
+
if (!controlKeys.includes(event.key)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (onKeyDown) {
|
|
26
|
+
onKeyDown(event);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_defineProperty(this, "setInputRef", ref => {
|
|
33
|
+
this.inputRef = ref;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
_defineProperty(this, "renderInputControls", () => {
|
|
37
|
+
return this.props.inputControls ? /*#__PURE__*/React.createElement(SearchInputControlsContainer, null, this.props.inputControls) : null;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
const {
|
|
43
|
+
children,
|
|
44
|
+
onBlur,
|
|
45
|
+
onInput,
|
|
46
|
+
placeholder,
|
|
47
|
+
isLoading,
|
|
48
|
+
value,
|
|
49
|
+
autocompleteText: autocomplete
|
|
50
|
+
} = this.props;
|
|
51
|
+
return /*#__PURE__*/React.createElement(SearchInner, null, /*#__PURE__*/React.createElement(SearchBox, null, /*#__PURE__*/React.createElement(SearchFieldBaseOuter, null, /*#__PURE__*/React.createElement(SearchFieldBaseInner, null, autocomplete && /*#__PURE__*/React.createElement(SearchInputTypeAhead, {
|
|
52
|
+
spellCheck: false,
|
|
53
|
+
type: "text",
|
|
54
|
+
value: `${autocomplete}`,
|
|
55
|
+
readOnly: true,
|
|
56
|
+
tabIndex: -1
|
|
57
|
+
}), /*#__PURE__*/React.createElement(SearchInput, {
|
|
58
|
+
autoFocus: true,
|
|
59
|
+
innerRef: this.setInputRef,
|
|
60
|
+
onBlur: onBlur,
|
|
61
|
+
onInput: onInput,
|
|
62
|
+
placeholder: placeholder,
|
|
63
|
+
spellCheck: false,
|
|
64
|
+
type: "text",
|
|
65
|
+
value: value,
|
|
66
|
+
onChange: () => {} // Suppresses the console warning, we handle onChange by using onKeyDown instead.
|
|
67
|
+
,
|
|
68
|
+
onKeyDown: this.onInputKeyDown
|
|
69
|
+
}), isLoading && /*#__PURE__*/React.createElement(SpinnerParent, null, /*#__PURE__*/React.createElement(Spinner, {
|
|
70
|
+
size: "small"
|
|
71
|
+
})))), this.renderInputControls()), children);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_defineProperty(Search, "defaultProps", {
|
|
77
|
+
isLoading: false,
|
|
78
|
+
onBlur: () => {},
|
|
79
|
+
placeholder: 'Search'
|
|
80
|
+
});
|