@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +763 -0
  2. package/LICENSE +13 -0
  3. package/build/tsconfig.json +17 -0
  4. package/dist/cjs/components/QuickSearch.js +447 -0
  5. package/dist/cjs/components/ResultItem/ResultItem.js +87 -0
  6. package/dist/cjs/components/ResultItem/ResultItemGroup.js +57 -0
  7. package/dist/cjs/components/ResultItem/styled.js +53 -0
  8. package/dist/cjs/components/Results/ContainerResult.js +93 -0
  9. package/dist/cjs/components/Results/ObjectResult.js +108 -0
  10. package/dist/cjs/components/Results/PersonResult.js +99 -0
  11. package/dist/cjs/components/Results/ResultBase.js +206 -0
  12. package/dist/cjs/components/Results/index.js +39 -0
  13. package/dist/cjs/components/Results/types.js +5 -0
  14. package/dist/cjs/components/Search/Search.js +124 -0
  15. package/dist/cjs/components/Search/styled.js +61 -0
  16. package/dist/cjs/components/constants.js +20 -0
  17. package/dist/cjs/components/context.js +29 -0
  18. package/dist/cjs/components/decorateWithAnalyticsData.js +80 -0
  19. package/dist/cjs/components/isReactElement.js +19 -0
  20. package/dist/cjs/index.js +94 -0
  21. package/dist/cjs/version.json +4 -0
  22. package/dist/es2019/components/QuickSearch.js +417 -0
  23. package/dist/es2019/components/ResultItem/ResultItem.js +41 -0
  24. package/dist/es2019/components/ResultItem/ResultItemGroup.js +16 -0
  25. package/dist/es2019/components/ResultItem/styled.js +54 -0
  26. package/dist/es2019/components/Results/ContainerResult.js +45 -0
  27. package/dist/es2019/components/Results/ObjectResult.js +60 -0
  28. package/dist/es2019/components/Results/PersonResult.js +50 -0
  29. package/dist/es2019/components/Results/ResultBase.js +149 -0
  30. package/dist/es2019/components/Results/index.js +4 -0
  31. package/dist/es2019/components/Results/types.js +1 -0
  32. package/dist/es2019/components/Search/Search.js +80 -0
  33. package/dist/es2019/components/Search/styled.js +76 -0
  34. package/dist/es2019/components/constants.js +7 -0
  35. package/dist/es2019/components/context.js +11 -0
  36. package/dist/es2019/components/decorateWithAnalyticsData.js +33 -0
  37. package/dist/es2019/components/isReactElement.js +10 -0
  38. package/dist/es2019/index.js +23 -0
  39. package/dist/es2019/version.json +4 -0
  40. package/dist/esm/components/QuickSearch.js +442 -0
  41. package/dist/esm/components/ResultItem/ResultItem.js +65 -0
  42. package/dist/esm/components/ResultItem/ResultItemGroup.js +42 -0
  43. package/dist/esm/components/ResultItem/styled.js +18 -0
  44. package/dist/esm/components/Results/ContainerResult.js +78 -0
  45. package/dist/esm/components/Results/ObjectResult.js +93 -0
  46. package/dist/esm/components/Results/PersonResult.js +86 -0
  47. package/dist/esm/components/Results/ResultBase.js +189 -0
  48. package/dist/esm/components/Results/index.js +4 -0
  49. package/dist/esm/components/Results/types.js +1 -0
  50. package/dist/esm/components/Search/Search.js +108 -0
  51. package/dist/esm/components/Search/styled.js +20 -0
  52. package/dist/esm/components/constants.js +7 -0
  53. package/dist/esm/components/context.js +13 -0
  54. package/dist/esm/components/decorateWithAnalyticsData.js +64 -0
  55. package/dist/esm/components/isReactElement.js +10 -0
  56. package/dist/esm/index.js +23 -0
  57. package/dist/esm/version.json +4 -0
  58. package/dist/types/components/QuickSearch.d.ts +122 -0
  59. package/dist/types/components/ResultItem/ResultItem.d.ts +38 -0
  60. package/dist/types/components/ResultItem/ResultItemGroup.d.ts +11 -0
  61. package/dist/types/components/ResultItem/styled.d.ts +13 -0
  62. package/dist/types/components/Results/ContainerResult.d.ts +19 -0
  63. package/dist/types/components/Results/ObjectResult.d.ts +22 -0
  64. package/dist/types/components/Results/PersonResult.d.ts +20 -0
  65. package/dist/types/components/Results/ResultBase.d.ts +37 -0
  66. package/dist/types/components/Results/index.d.ts +4 -0
  67. package/dist/types/components/Results/types.d.ts +34 -0
  68. package/dist/types/components/Search/Search.d.ts +31 -0
  69. package/dist/types/components/Search/styled.d.ts +10 -0
  70. package/dist/types/components/constants.d.ts +6 -0
  71. package/dist/types/components/context.d.ts +22 -0
  72. package/dist/types/components/decorateWithAnalyticsData.d.ts +3 -0
  73. package/dist/types/components/isReactElement.d.ts +6 -0
  74. package/dist/types/index.d.ts +17 -0
  75. package/docs/0-intro.tsx +53 -0
  76. package/package.json +52 -0
  77. package/tsconfig.json +11 -0
@@ -0,0 +1,4 @@
1
+ export { default as ContainerResult } from './ContainerResult';
2
+ export { default as ObjectResult } from './ObjectResult';
3
+ export { default as PersonResult } from './PersonResult';
4
+ export { default as ResultBase } from './ResultBase';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,108 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
9
+
10
+ var _templateObject;
11
+
12
+ 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); }; }
13
+
14
+ 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; } }
15
+
16
+ import React from 'react';
17
+ import Spinner from '@atlaskit/spinner';
18
+ import styled from 'styled-components';
19
+ import { SearchBox, SearchFieldBaseInner, SearchInner, SearchInput, SearchFieldBaseOuter, SearchInputControlsContainer, SearchInputTypeAhead } from './styled';
20
+ export var controlKeys = ['ArrowUp', 'ArrowDown', 'Enter', 'Tab', 'ArrowRight'];
21
+ var SpinnerParent = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 20px;\n margin-left: 10px;\n margin-top: 10px;\n"])));
22
+
23
+ var Search = /*#__PURE__*/function (_React$PureComponent) {
24
+ _inherits(Search, _React$PureComponent);
25
+
26
+ var _super = _createSuper(Search);
27
+
28
+ function Search() {
29
+ var _this;
30
+
31
+ _classCallCheck(this, Search);
32
+
33
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
34
+ args[_key] = arguments[_key];
35
+ }
36
+
37
+ _this = _super.call.apply(_super, [this].concat(args));
38
+
39
+ _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) {
40
+ var onKeyDown = _this.props.onKeyDown;
41
+
42
+ if (!controlKeys.includes(event.key)) {
43
+ return;
44
+ }
45
+
46
+ if (onKeyDown) {
47
+ onKeyDown(event);
48
+ }
49
+
50
+ event.stopPropagation();
51
+ });
52
+
53
+ _defineProperty(_assertThisInitialized(_this), "setInputRef", function (ref) {
54
+ _this.inputRef = ref;
55
+ });
56
+
57
+ _defineProperty(_assertThisInitialized(_this), "renderInputControls", function () {
58
+ return _this.props.inputControls ? /*#__PURE__*/React.createElement(SearchInputControlsContainer, null, _this.props.inputControls) : null;
59
+ });
60
+
61
+ return _this;
62
+ }
63
+
64
+ _createClass(Search, [{
65
+ key: "render",
66
+ value: function render() {
67
+ var _this$props = this.props,
68
+ children = _this$props.children,
69
+ onBlur = _this$props.onBlur,
70
+ onInput = _this$props.onInput,
71
+ placeholder = _this$props.placeholder,
72
+ isLoading = _this$props.isLoading,
73
+ value = _this$props.value,
74
+ autocomplete = _this$props.autocompleteText;
75
+ 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, {
76
+ spellCheck: false,
77
+ type: "text",
78
+ value: "".concat(autocomplete),
79
+ readOnly: true,
80
+ tabIndex: -1
81
+ }), /*#__PURE__*/React.createElement(SearchInput, {
82
+ autoFocus: true,
83
+ innerRef: this.setInputRef,
84
+ onBlur: onBlur,
85
+ onInput: onInput,
86
+ placeholder: placeholder,
87
+ spellCheck: false,
88
+ type: "text",
89
+ value: value,
90
+ onChange: function onChange() {} // Suppresses the console warning, we handle onChange by using onKeyDown instead.
91
+ ,
92
+ onKeyDown: this.onInputKeyDown
93
+ }), isLoading && /*#__PURE__*/React.createElement(SpinnerParent, null, /*#__PURE__*/React.createElement(Spinner, {
94
+ size: "small"
95
+ })))), this.renderInputControls()), children);
96
+ }
97
+ }]);
98
+
99
+ return Search;
100
+ }(React.PureComponent);
101
+
102
+ _defineProperty(Search, "defaultProps", {
103
+ isLoading: false,
104
+ onBlur: function onBlur() {},
105
+ placeholder: 'Search'
106
+ });
107
+
108
+ export { Search as default };
@@ -0,0 +1,20 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
4
+
5
+ import styled, { css } from 'styled-components';
6
+ import { gridSize } from '@atlaskit/theme/constants';
7
+ import { N0, N500, B200, placeholderText, N50 } from '@atlaskit/theme/colors';
8
+ var inputRightPadding = gridSize() * 2;
9
+ export var SearchBox = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n z-index: 1; /* required to keep the search box on top of icons in results when sticky */\n background-color: ", ";\n color: ", ";\n display: flex;\n height: 36px;\n z-index: 10;\n"])), N0, N500);
10
+ export var SearchFieldBaseOuter = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n margin-right: auto;\n padding-bottom: 2px;\n border-bottom: 2px solid ", ";\n"])), B200);
11
+ export var SearchFieldBaseInner = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n align-items: center;\n padding-right: ", "px; /* pad search text from FieldBase's isLoading spinner */\n display: flex;\n flex-grow: 1;\n"])), inputRightPadding);
12
+ export var SearchInner = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding-right: ", "px;\n"])), gridSize() * 3);
13
+ export var getPlaceholderStyle = function getPlaceholderStyle(style) {
14
+ return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n &::-webkit-input-placeholder {\n ", ";\n }\n &::-moz-placeholder {\n /* Mozilla Firefox 19+ */\n ", " opacity: 1;\n }\n &::-ms-input-placeholder {\n /* Microsoft Edge */\n ", ";\n }\n &:-moz-placeholder {\n /* Mozilla Firefox 4 to 18 */\n ", " opacity: 1;\n }\n &:-ms-input-placeholder {\n /* Internet Explorer 10-11 */\n ", ";\n }\n"])), style, style, style, style, style);
15
+ };
16
+ export var getPlaceholderColor = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n"])), placeholderText);
17
+ export var SearchInput = styled.input(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background-color: transparent;\n border: 0;\n color: ", ";\n flex-grow: 1;\n font-size: 1.4em;\n outline: 0;\n // Safari adds 2px margin-left\n margin-left: 0;\n ", ";\n"])), N500, getPlaceholderStyle(getPlaceholderColor));
18
+ export var SearchInputTypeAhead = styled(SearchInput)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n color: ", ";\n position: absolute;\n width: calc(100% - ", "px);\n z-index: -1;\n"])), N50, inputRightPadding);
19
+ export var SearchInputControlsContainer = styled.span(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n padding-left: ", "px;\n"])), gridSize() * 3);
20
+ SearchInputControlsContainer.displayName = 'SearchInputControlsContainer'; // required for testing
@@ -0,0 +1,7 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export var ATLASKIT_QUICKSEARCH_NS = 'atlaskit.navigation.quick-search';
3
+ export var QS_ANALYTICS_EV_CLOSE = "".concat(ATLASKIT_QUICKSEARCH_NS, ".close");
4
+ export var QS_ANALYTICS_EV_KB_CTRLS_USED = "".concat(ATLASKIT_QUICKSEARCH_NS, ".keyboard-controls-used");
5
+ export var QS_ANALYTICS_EV_OPEN = "".concat(ATLASKIT_QUICKSEARCH_NS, ".open");
6
+ export var QS_ANALYTICS_EV_QUERY_ENTERED = "".concat(ATLASKIT_QUICKSEARCH_NS, ".query-entered");
7
+ export var QS_ANALYTICS_EV_SUBMIT = "".concat(ATLASKIT_QUICKSEARCH_NS, ".submit");
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ var defaultState = {
3
+ sendAnalytics: function sendAnalytics() {},
4
+ onMouseEnter: function onMouseEnter() {},
5
+ onMouseLeave: function onMouseLeave() {},
6
+ registerResult: function registerResult() {},
7
+ unregisterResult: function unregisterResult() {},
8
+ getIndex: function getIndex(n) {
9
+ return Number(n);
10
+ }
11
+ };
12
+ export var ResultContext = /*#__PURE__*/React.createContext(defaultState);
13
+ export var SelectedResultIdContext = /*#__PURE__*/React.createContext(null);
@@ -0,0 +1,64 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ 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); }; }
10
+
11
+ 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; } }
12
+
13
+ import React from 'react';
14
+ import { AnalyticsDecorator } from '@atlaskit/analytics';
15
+ import isReactElement from './isReactElement';
16
+ import { QS_ANALYTICS_EV_SUBMIT } from './constants';
17
+ export default function decorateWithAnalyticsData(WrappedQuickSearch) {
18
+ var _class, _temp;
19
+
20
+ return _temp = _class = /*#__PURE__*/function (_React$Component) {
21
+ _inherits(DecorateWithAnalyticsData, _React$Component);
22
+
23
+ var _super = _createSuper(DecorateWithAnalyticsData);
24
+
25
+ function DecorateWithAnalyticsData() {
26
+ var _this;
27
+
28
+ _classCallCheck(this, DecorateWithAnalyticsData);
29
+
30
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
+ args[_key] = arguments[_key];
32
+ }
33
+
34
+ _this = _super.call.apply(_super, [this].concat(args));
35
+
36
+ _defineProperty(_assertThisInitialized(_this), "countChildren", function () {
37
+ return React.Children.toArray(_this.props.children).reduce(function (total, group) {
38
+ return isReactElement(group) ? total + React.Children.count(group.props.children) : total;
39
+ }, 0);
40
+ });
41
+
42
+ return _this;
43
+ }
44
+
45
+ _createClass(DecorateWithAnalyticsData, [{
46
+ key: "render",
47
+ value: function render() {
48
+ return /*#__PURE__*/React.createElement(AnalyticsDecorator, {
49
+ matchPrivate: true,
50
+ match: QS_ANALYTICS_EV_SUBMIT,
51
+ data: {
52
+ resultCount: this.countChildren(),
53
+ queryLength: this.props.value.length
54
+ }
55
+ }, /*#__PURE__*/React.createElement(WrappedQuickSearch, this.props));
56
+ }
57
+ }]);
58
+
59
+ return DecorateWithAnalyticsData;
60
+ }(React.Component), _defineProperty(_class, "defaultProps", {
61
+ children: [],
62
+ value: ''
63
+ }), _temp;
64
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Heuristically check whether an element is a react element or not.
3
+ * React elements have constructors for their type property but native elements use strings.
4
+ */
5
+ export default (function (element) {
6
+ var type = element && element.type;
7
+ var hasFunctionAsType = !!type && typeof type === 'function';
8
+ var hasProps = element && element.props;
9
+ return hasFunctionAsType && hasProps;
10
+ });
@@ -0,0 +1,23 @@
1
+ import * as resultTypes from './components/Results';
2
+ /*
3
+ This component is exported in two different ways.
4
+
5
+ v0: A legacy, backwards compatible API from when quick-search was living inside @atlaskit/navigation. This API
6
+ is deprecated and will be removed in the next major version.
7
+
8
+ v1: An API tailored to a stand-alone quick-search component.
9
+ */
10
+ // API v0 Exports:
11
+
12
+ export { default as AkNavigationItemGroup } from './components/ResultItem/ResultItemGroup';
13
+ export { default as AkNavigationItem } from './components/ResultItem/ResultItem';
14
+ export { default as AkQuickSearch } from './components/QuickSearch';
15
+ export { default as AkSearch } from './components/Search/Search';
16
+ export { resultTypes as quickSearchResultTypes }; // API v1 Exports:
17
+
18
+ export { default as QuickSearch } from './components/QuickSearch';
19
+ export { default as ResultItemGroup } from './components/ResultItem/ResultItemGroup';
20
+ export { default as ObjectResult } from './components/Results/ObjectResult';
21
+ export { default as PersonResult } from './components/Results/PersonResult';
22
+ export { default as ContainerResult } from './components/Results/ContainerResult';
23
+ export { default as ResultBase } from './components/Results/ResultBase'; // types
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@atlaskit/quick-search",
3
+ "version": "8.0.9"
4
+ }
@@ -0,0 +1,122 @@
1
+ import React from 'react';
2
+ import { ResultData, SelectedResultId } from './Results/types';
3
+ import { ResultContextType } from './context';
4
+ import { ResultBase } from './Results/ResultBase';
5
+ export declare type Props = {
6
+ /** Search results in the form of ResultItemGroups containing Result components */
7
+ children: React.ReactNode;
8
+ /** Set search loading state */
9
+ isLoading?: boolean;
10
+ /** onBlur callback for search input */
11
+ onSearchBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
12
+ /** onInput callback for search input */
13
+ onSearchInput?: (event: React.FormEvent<HTMLInputElement>, isAutocompleted?: boolean) => void;
14
+ /** onKeyDown callback for search input */
15
+ onSearchKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
16
+ /** Called when the user submits the search form without selecting a result */
17
+ onSearchSubmit?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
18
+ /** Placeholder text for search input field */
19
+ placeholder?: string;
20
+ /** Value of the search input field */
21
+ value?: string;
22
+ /** Corresponds to the `resultId` of the selected result */
23
+ selectedResultId?: SelectedResultId;
24
+ /** Optional way of being notified when the selected result changes due to keyboard nav */
25
+ onSelectedResultIdChanged?: (id: SelectedResultId) => void;
26
+ firePrivateAnalyticsEvent?: (eventName: string, eventData: Object) => void;
27
+ /** React component to be used for rendering links */
28
+ linkComponent?: React.ComponentType<any>;
29
+ /** The elements to render to the right of the search input. */
30
+ inputControls?: React.ReactNode;
31
+ /** One string that is used to autocomplete the current search query */
32
+ autocompleteText?: string;
33
+ };
34
+ export declare type State = {
35
+ selectedResultId: SelectedResultId;
36
+ context: ResultContextType;
37
+ value?: string;
38
+ };
39
+ export declare class QuickSearch extends React.Component<Props, State> {
40
+ static defaultProps: {
41
+ children: never[];
42
+ firePrivateAnalyticsEvent: (_: any) => void;
43
+ isLoading: boolean;
44
+ onSearchBlur: (_: any) => void;
45
+ onSearchKeyDown: (_: any) => void;
46
+ onSearchSubmit: (_: any) => void;
47
+ placeholder: string;
48
+ value: string;
49
+ };
50
+ inputSearchRef?: React.Ref<any>;
51
+ flatResults: Array<ResultBase>;
52
+ hasSearchQueryEventFired: boolean;
53
+ hasKeyDownEventFired: boolean;
54
+ lastKeyPressed: string;
55
+ constructor(props: Props);
56
+ componentDidMount(): void;
57
+ componentWillUnmount(): void;
58
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
59
+ fireKeyboardControlEvent(selectedResultId: SelectedResultId): void;
60
+ /**
61
+ * Uses the virtual list, this.flatResults, to move the selection across grouped results as if
62
+ * results were in a single, circular list.
63
+ *
64
+ * Process:
65
+ * 1. Finds the index of the selected result in the flatResults array,
66
+ * 2. Increments or decrements this index by the supplied adjustment amount,
67
+ * 3. Sets the new selectedResultId based on the modifed index
68
+ */
69
+ adjustSelectedResultIndex: (adjustment: number) => void;
70
+ /** Select next result */
71
+ selectNext: () => void;
72
+ /** Select previous result */
73
+ selectPrevious: () => void;
74
+ /**
75
+ * Callback for register results in flatResults
76
+ */
77
+ handleRegisterResult: (result: ResultBase) => void;
78
+ /**
79
+ * Callback for unregister results in flatResults
80
+ * It will reconcile a list of results for keyboard navigation after every update.
81
+ * 1. Component starts with an empty list of results
82
+ * 2. componentDidMount / componentDidUpdate lifecycle methods in ResultBase will be invoked
83
+ * 3. All ResultBase components call registerResult() in order to register itself in quick search
84
+ * 4. All ResultBase components call unregisterResult() in order to unregister itself in quick search
85
+ */
86
+ handleUnregisterResult: (result: ResultBase) => void;
87
+ /**
88
+ * Callback for mouseEnter events on individual results
89
+ * Move selection to hovered result
90
+ */
91
+ handleResultMouseEnter: (resultData: ResultData) => void;
92
+ /**
93
+ * Callback for mouseLeave events on individual results
94
+ * Clear result selection
95
+ */
96
+ handleResultMouseLeave: () => void;
97
+ /**
98
+ * Clear result selection when search input is blurred
99
+ */
100
+ handleSearchBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
101
+ onInput: (event: React.FormEvent<HTMLInputElement>) => void;
102
+ /**
103
+ * Keyboard controls
104
+ * Up - Select previous result
105
+ * Down - Select next result
106
+ * Enter - Submit selected result
107
+ * Tab / ArrowRight - Accept autocomplete
108
+ */
109
+ handleSearchKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
110
+ acceptAutocomplete: (event: React.KeyboardEvent<HTMLInputElement>, text?: string | undefined) => void;
111
+ setSearchInputRef: (refs: any) => void;
112
+ focusSearchInput: () => void;
113
+ render(): JSX.Element;
114
+ }
115
+ declare const _default: React.ComponentClass<Props, any>;
116
+ /**
117
+ * HOCs:
118
+ * `decorateWithAnalyticsData` - Wrapper that decorates analytics events with additional data.
119
+ * `withAnalytics` - Injects analytics firing methods that are picked up by
120
+ * @atlaskit/analytics/AnalyticsListener.
121
+ */
122
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ /** Text to appear to the right of the text. It has a lower font-weight. */
4
+ caption?: string;
5
+ /** Location to link out to on click. This is passed down to the custom link component if one is provided. */
6
+ href?: string;
7
+ /** Target frame for item `href` link to be aimed at. */
8
+ target?: string;
9
+ /** React element to appear to the left of the text. This should be an @atlaskit/icon component. */
10
+ icon?: React.ReactNode;
11
+ /** Makes the navigation item appear with reduced padding and font size. */
12
+ isCompact?: boolean;
13
+ /** Set whether the item should be highlighted as selected. Selected items have a different background color. */
14
+ isSelected?: boolean;
15
+ /** Set whether the item has been highlighted using mouse navigation. Mouse selected items will not display the selectedIcon. */
16
+ isMouseSelected?: boolean;
17
+ /** Function to be called on click. This is passed down to a custom link component, if one is provided. */
18
+ onClick?(e: MouseEvent): void;
19
+ /** Standard onmouseenter event */
20
+ onMouseEnter?: (e: MouseEvent) => void;
21
+ /** Standard onmouseleave event */
22
+ onMouseLeave?: (e: MouseEvent) => void;
23
+ /** Text to be shown alongside the main `text`. */
24
+ subText?: React.ReactNode;
25
+ /** Main text to be displayed as the item. Accepts a react component but in most cases this should just be a string. */
26
+ text?: React.ReactNode;
27
+ /** React component to be placed to the right of the main text. */
28
+ textAfter?: React.ReactNode;
29
+ /** React component to be placed to the right of the main text when the item is selected with keyboard navigation. */
30
+ selectedIcon?: React.ReactNode;
31
+ /** React component to be used for rendering links */
32
+ linkComponent?: React.ComponentType;
33
+ };
34
+ declare class ResultItem extends React.PureComponent<Props> {
35
+ static defaultProps: Partial<Props>;
36
+ render(): JSX.Element;
37
+ }
38
+ export default ResultItem;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ /** Text to appear as heading above group. Will be auto-capitalised. */
4
+ title: React.ReactNode;
5
+ /** React Elements to be displayed within the group. This should generally be a collection of ResultItems. */
6
+ children?: React.ReactNode;
7
+ };
8
+ export default class ResultItemGroup extends React.Component<Props> {
9
+ render(): JSX.Element;
10
+ }
11
+ export {};