@docsearch/react 3.0.0-alpha.39 → 3.0.0-alpha.50
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/README.md +30 -4
- package/dist/esm/AlgoliaLogo.d.ts +8 -1
- package/dist/esm/AlgoliaLogo.js +7 -3
- package/dist/esm/DocSearch.d.ts +20 -10
- package/dist/esm/DocSearch.js +8 -4
- package/dist/esm/DocSearchButton.d.ts +3 -4
- package/dist/esm/DocSearchButton.js +3 -1
- package/dist/esm/DocSearchModal.d.ts +13 -5
- package/dist/esm/DocSearchModal.js +57 -40
- package/dist/esm/ErrorScreen.d.ts +9 -1
- package/dist/esm/ErrorScreen.js +9 -3
- package/dist/esm/Footer.d.ts +11 -1
- package/dist/esm/Footer.js +33 -18
- package/dist/esm/Hit.d.ts +2 -2
- package/dist/esm/NoResultsScreen.d.ts +12 -4
- package/dist/esm/NoResultsScreen.js +29 -8
- package/dist/esm/Results.d.ts +8 -8
- package/dist/esm/Results.js +1 -1
- package/dist/esm/ResultsScreen.d.ts +3 -3
- package/dist/esm/ResultsScreen.js +2 -2
- package/dist/esm/ScreenState.d.ts +17 -7
- package/dist/esm/ScreenState.js +19 -4
- package/dist/esm/SearchBox.d.ts +13 -5
- package/dist/esm/SearchBox.js +25 -3
- package/dist/esm/Snippet.d.ts +2 -2
- package/dist/esm/Snippet.js +8 -5
- package/dist/esm/StartScreen.d.ts +14 -5
- package/dist/esm/StartScreen.js +40 -14
- package/dist/esm/__tests__/api.test.js +336 -0
- package/dist/esm/icons/SourceIcon.js +14 -13
- package/dist/esm/stored-searches.d.ts +4 -4
- package/dist/esm/stored-searches.js +3 -1
- package/dist/esm/types/DocSearchHit.d.ts +2 -2
- package/dist/esm/types/DocSearchHit.js +1 -0
- package/dist/esm/types/InternalDocSearchHit.d.ts +2 -2
- package/dist/esm/types/InternalDocSearchHit.js +1 -0
- package/dist/esm/types/StoredDocSearchHit.d.ts +1 -1
- package/dist/esm/types/StoredDocSearchHit.js +1 -0
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +3 -3
- package/dist/esm/useSearchClient.d.ts +1 -1
- package/dist/esm/useTouchEvents.d.ts +1 -1
- package/dist/esm/utils/groupBy.d.ts +1 -1
- package/dist/esm/utils/removeHighlightTags.d.ts +1 -1
- package/dist/esm/utils/removeHighlightTags.js +6 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,16 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
React package for [DocSearch](http://docsearch.algolia.com/), the best search experience for docs.
|
|
4
4
|
|
|
5
|
-
[](https://percy.io/DX/DocSearch)
|
|
6
|
-
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
|
-
```
|
|
7
|
+
```bash
|
|
10
8
|
yarn add @docsearch/react@alpha
|
|
11
9
|
# or
|
|
12
10
|
npm install @docsearch/react@alpha
|
|
13
11
|
```
|
|
14
12
|
|
|
13
|
+
If you don’t want to use a package manager, you can use a standalone endpoint:
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script src="https://cdn.jsdelivr.net/npm/@docsearch/react@alpha"></script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Get started
|
|
20
|
+
|
|
21
|
+
DocSearch generates a fully accessible search box for you.
|
|
22
|
+
|
|
23
|
+
```jsx App.js
|
|
24
|
+
import { DocSearch } from '@docsearch/react';
|
|
25
|
+
|
|
26
|
+
import '@docsearch/css';
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<DocSearch
|
|
31
|
+
appId="YOUR_APP_ID"
|
|
32
|
+
indexName="YOUR_INDEX_NAME"
|
|
33
|
+
apiKey="YOUR_SEARCH_API_KEY"
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default App;
|
|
39
|
+
```
|
|
40
|
+
|
|
15
41
|
## Documentation
|
|
16
42
|
|
|
17
|
-
[Read documentation →](https://
|
|
43
|
+
[Read documentation →](https://docsearch.algolia.com/docs/DocSearch-v3)
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
declare type AlgoliaLogoTranslations = Partial<{
|
|
3
|
+
searchByText: string;
|
|
4
|
+
}>;
|
|
5
|
+
declare type AlgoliaLogoProps = {
|
|
6
|
+
translations?: AlgoliaLogoTranslations;
|
|
7
|
+
};
|
|
8
|
+
export declare function AlgoliaLogo({ translations }: AlgoliaLogoProps): JSX.Element;
|
|
9
|
+
export {};
|
package/dist/esm/AlgoliaLogo.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export function AlgoliaLogo() {
|
|
2
|
+
export function AlgoliaLogo(_ref) {
|
|
3
|
+
var _ref$translations = _ref.translations,
|
|
4
|
+
translations = _ref$translations === void 0 ? {} : _ref$translations;
|
|
5
|
+
var _translations$searchB = translations.searchByText,
|
|
6
|
+
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
|
|
3
7
|
return /*#__PURE__*/React.createElement("a", {
|
|
4
|
-
href: "https://www.algolia.com/docsearch",
|
|
8
|
+
href: "https://www.algolia.com/ref/docsearch/?utm_source=".concat(window.location.hostname, "&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch"),
|
|
5
9
|
target: "_blank",
|
|
6
10
|
rel: "noopener noreferrer"
|
|
7
11
|
}, /*#__PURE__*/React.createElement("span", {
|
|
8
12
|
className: "DocSearch-Label"
|
|
9
|
-
},
|
|
13
|
+
}, searchByText), /*#__PURE__*/React.createElement("svg", {
|
|
10
14
|
width: "77",
|
|
11
15
|
height: "19"
|
|
12
16
|
}, /*#__PURE__*/React.createElement("path", {
|
package/dist/esm/DocSearch.d.ts
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
2
|
-
import {
|
|
1
|
+
import type { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
2
|
+
import type { SearchOptions } from '@algolia/client-search';
|
|
3
|
+
import type { SearchClient } from 'algoliasearch/lite';
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
5
|
+
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
6
|
+
import type { ButtonTranslations, ModalTranslations } from '.';
|
|
7
|
+
export declare type DocSearchTranslations = Partial<{
|
|
8
|
+
button: ButtonTranslations;
|
|
9
|
+
modal: ModalTranslations;
|
|
10
|
+
}>;
|
|
5
11
|
export interface DocSearchProps {
|
|
6
12
|
appId?: string;
|
|
7
13
|
apiKey: string;
|
|
8
14
|
indexName: string;
|
|
9
15
|
placeholder?: string;
|
|
10
|
-
searchParameters?:
|
|
11
|
-
transformItems
|
|
12
|
-
hitComponent
|
|
16
|
+
searchParameters?: SearchOptions;
|
|
17
|
+
transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
|
|
18
|
+
hitComponent?: (props: {
|
|
13
19
|
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
14
20
|
children: React.ReactNode;
|
|
15
|
-
})
|
|
16
|
-
resultsFooterComponent
|
|
21
|
+
}) => JSX.Element;
|
|
22
|
+
resultsFooterComponent?: (props: {
|
|
17
23
|
state: AutocompleteState<InternalDocSearchHit>;
|
|
18
|
-
})
|
|
19
|
-
transformSearchClient
|
|
24
|
+
}) => JSX.Element | null;
|
|
25
|
+
transformSearchClient?: (searchClient: SearchClient) => SearchClient;
|
|
20
26
|
disableUserPersonalization?: boolean;
|
|
21
27
|
initialQuery?: string;
|
|
22
28
|
navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
|
|
29
|
+
translations?: DocSearchTranslations;
|
|
30
|
+
getMissingResultsUrl?: ({ query: string }: {
|
|
31
|
+
query: any;
|
|
32
|
+
}) => string;
|
|
23
33
|
}
|
|
24
34
|
export declare function DocSearch(props: DocSearchProps): JSX.Element;
|
package/dist/esm/DocSearch.js
CHANGED
|
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
|
|
9
9
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
10
|
|
|
11
|
-
function _iterableToArrayLimit(arr, i) {
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
12
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
|
|
@@ -18,6 +18,8 @@ import { DocSearchButton } from './DocSearchButton';
|
|
|
18
18
|
import { DocSearchModal } from './DocSearchModal';
|
|
19
19
|
import { useDocSearchKeyboardEvents } from './useDocSearchKeyboardEvents';
|
|
20
20
|
export function DocSearch(props) {
|
|
21
|
+
var _props$translations, _props$translations2;
|
|
22
|
+
|
|
21
23
|
var searchButtonRef = React.useRef(null);
|
|
22
24
|
|
|
23
25
|
var _React$useState = React.useState(false),
|
|
@@ -25,7 +27,7 @@ export function DocSearch(props) {
|
|
|
25
27
|
isOpen = _React$useState2[0],
|
|
26
28
|
setIsOpen = _React$useState2[1];
|
|
27
29
|
|
|
28
|
-
var _React$useState3 = React.useState(undefined),
|
|
30
|
+
var _React$useState3 = React.useState((props === null || props === void 0 ? void 0 : props.initialQuery) || undefined),
|
|
29
31
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
30
32
|
initialQuery = _React$useState4[0],
|
|
31
33
|
setInitialQuery = _React$useState4[1];
|
|
@@ -48,11 +50,13 @@ export function DocSearch(props) {
|
|
|
48
50
|
searchButtonRef: searchButtonRef
|
|
49
51
|
});
|
|
50
52
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DocSearchButton, {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
ref: searchButtonRef,
|
|
54
|
+
translations: props === null || props === void 0 ? void 0 : (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
|
|
55
|
+
onClick: onOpen
|
|
53
56
|
}), isOpen && createPortal( /*#__PURE__*/React.createElement(DocSearchModal, _extends({}, props, {
|
|
54
57
|
initialScrollY: window.scrollY,
|
|
55
58
|
initialQuery: initialQuery,
|
|
59
|
+
translations: props === null || props === void 0 ? void 0 : (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
|
|
56
60
|
onClose: onClose
|
|
57
61
|
})), document.body));
|
|
58
62
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare type
|
|
2
|
+
export declare type ButtonTranslations = Partial<{
|
|
3
3
|
buttonText: string;
|
|
4
4
|
buttonAriaLabel: string;
|
|
5
5
|
}>;
|
|
6
6
|
export declare type DocSearchButtonProps = React.ComponentProps<'button'> & {
|
|
7
|
-
translations?:
|
|
7
|
+
translations?: ButtonTranslations;
|
|
8
8
|
};
|
|
9
|
-
export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "
|
|
10
|
-
export {};
|
|
9
|
+
export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "translations" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var _excluded = ["translations"];
|
|
2
|
+
|
|
1
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
4
|
|
|
3
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -17,7 +19,7 @@ function isAppleDevice() {
|
|
|
17
19
|
export var DocSearchButton = React.forwardRef(function (_ref, ref) {
|
|
18
20
|
var _ref$translations = _ref.translations,
|
|
19
21
|
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
20
|
-
props = _objectWithoutProperties(_ref,
|
|
22
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
23
|
|
|
22
24
|
var _translations$buttonT = translations.buttonText,
|
|
23
25
|
buttonText = _translations$buttonT === void 0 ? 'Search' : _translations$buttonT,
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DocSearchProps } from './DocSearch';
|
|
3
|
-
|
|
2
|
+
import type { DocSearchProps } from './DocSearch';
|
|
3
|
+
import type { FooterTranslations } from './Footer';
|
|
4
|
+
import type { ScreenStateTranslations } from './ScreenState';
|
|
5
|
+
import type { SearchBoxTranslations } from './SearchBox';
|
|
6
|
+
export declare type ModalTranslations = Partial<{
|
|
7
|
+
searchBox: SearchBoxTranslations;
|
|
8
|
+
footer: FooterTranslations;
|
|
9
|
+
}> & ScreenStateTranslations;
|
|
10
|
+
export declare type DocSearchModalProps = DocSearchProps & {
|
|
4
11
|
initialScrollY: number;
|
|
5
|
-
onClose
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
translations?: ModalTranslations;
|
|
14
|
+
};
|
|
15
|
+
export declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, }: DocSearchModalProps): JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
var _excluded = ["footer", "searchBox"];
|
|
2
|
+
|
|
1
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
4
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
6
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
8
|
|
|
7
9
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
10
|
|
|
@@ -14,10 +16,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
14
16
|
|
|
15
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
18
|
|
|
17
|
-
function _iterableToArrayLimit(arr, i) {
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
20
|
|
|
19
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
22
|
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
|
|
25
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
|
+
|
|
21
27
|
import { createAutocomplete } from '@algolia/autocomplete-core';
|
|
22
28
|
import React from 'react';
|
|
23
29
|
import { MAX_QUERY_SIZE } from './constants';
|
|
@@ -56,7 +62,14 @@ export function DocSearchModal(_ref) {
|
|
|
56
62
|
_ref$disableUserPerso = _ref.disableUserPersonalization,
|
|
57
63
|
disableUserPersonalization = _ref$disableUserPerso === void 0 ? false : _ref$disableUserPerso,
|
|
58
64
|
_ref$initialQuery = _ref.initialQuery,
|
|
59
|
-
initialQueryFromProp = _ref$initialQuery === void 0 ? '' : _ref$initialQuery
|
|
65
|
+
initialQueryFromProp = _ref$initialQuery === void 0 ? '' : _ref$initialQuery,
|
|
66
|
+
_ref$translations = _ref.translations,
|
|
67
|
+
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
68
|
+
getMissingResultsUrl = _ref.getMissingResultsUrl;
|
|
69
|
+
|
|
70
|
+
var footerTranslations = translations.footer,
|
|
71
|
+
searchBoxTranslations = translations.searchBox,
|
|
72
|
+
screenStateTranslations = _objectWithoutProperties(translations, _excluded);
|
|
60
73
|
|
|
61
74
|
var _React$useState = React.useState({
|
|
62
75
|
query: '',
|
|
@@ -117,16 +130,14 @@ export function DocSearchModal(_ref) {
|
|
|
117
130
|
}
|
|
118
131
|
},
|
|
119
132
|
navigator: navigator,
|
|
120
|
-
onStateChange: function onStateChange(
|
|
121
|
-
|
|
122
|
-
setState(state);
|
|
133
|
+
onStateChange: function onStateChange(props) {
|
|
134
|
+
setState(props.state);
|
|
123
135
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
setStatus = _ref3.setStatus;
|
|
136
|
+
getSources: function getSources(_ref2) {
|
|
137
|
+
var query = _ref2.query,
|
|
138
|
+
sourcesState = _ref2.state,
|
|
139
|
+
setContext = _ref2.setContext,
|
|
140
|
+
setStatus = _ref2.setStatus;
|
|
130
141
|
|
|
131
142
|
if (!query) {
|
|
132
143
|
if (disableUserPersonalization) {
|
|
@@ -135,17 +146,17 @@ export function DocSearchModal(_ref) {
|
|
|
135
146
|
|
|
136
147
|
return [{
|
|
137
148
|
sourceId: 'recentSearches',
|
|
138
|
-
onSelect: function onSelect(
|
|
139
|
-
var item =
|
|
140
|
-
event =
|
|
149
|
+
onSelect: function onSelect(_ref3) {
|
|
150
|
+
var item = _ref3.item,
|
|
151
|
+
event = _ref3.event;
|
|
141
152
|
saveRecentSearch(item);
|
|
142
153
|
|
|
143
154
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
144
155
|
onClose();
|
|
145
156
|
}
|
|
146
157
|
},
|
|
147
|
-
getItemUrl: function getItemUrl(
|
|
148
|
-
var item =
|
|
158
|
+
getItemUrl: function getItemUrl(_ref4) {
|
|
159
|
+
var item = _ref4.item;
|
|
149
160
|
return item.url;
|
|
150
161
|
},
|
|
151
162
|
getItems: function getItems() {
|
|
@@ -153,17 +164,17 @@ export function DocSearchModal(_ref) {
|
|
|
153
164
|
}
|
|
154
165
|
}, {
|
|
155
166
|
sourceId: 'favoriteSearches',
|
|
156
|
-
onSelect: function onSelect(
|
|
157
|
-
var item =
|
|
158
|
-
event =
|
|
167
|
+
onSelect: function onSelect(_ref5) {
|
|
168
|
+
var item = _ref5.item,
|
|
169
|
+
event = _ref5.event;
|
|
159
170
|
saveRecentSearch(item);
|
|
160
171
|
|
|
161
172
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
162
173
|
onClose();
|
|
163
174
|
}
|
|
164
175
|
},
|
|
165
|
-
getItemUrl: function getItemUrl(
|
|
166
|
-
var item =
|
|
176
|
+
getItemUrl: function getItemUrl(_ref6) {
|
|
177
|
+
var item = _ref6.item;
|
|
167
178
|
return item.url;
|
|
168
179
|
},
|
|
169
180
|
getItems: function getItems() {
|
|
@@ -193,8 +204,8 @@ export function DocSearchModal(_ref) {
|
|
|
193
204
|
}
|
|
194
205
|
|
|
195
206
|
throw error;
|
|
196
|
-
}).then(function (
|
|
197
|
-
var results =
|
|
207
|
+
}).then(function (_ref7) {
|
|
208
|
+
var results = _ref7.results;
|
|
198
209
|
var _results$ = results[0],
|
|
199
210
|
hits = _results$.hits,
|
|
200
211
|
nbHits = _results$.nbHits;
|
|
@@ -203,7 +214,7 @@ export function DocSearchModal(_ref) {
|
|
|
203
214
|
}); // We store the `lvl0`s to display them as search suggestions
|
|
204
215
|
// in the "no results" screen.
|
|
205
216
|
|
|
206
|
-
if (
|
|
217
|
+
if (sourcesState.context.searchSuggestions.length < Object.keys(sources).length) {
|
|
207
218
|
setContext({
|
|
208
219
|
searchSuggestions: Object.keys(sources)
|
|
209
220
|
});
|
|
@@ -215,27 +226,26 @@ export function DocSearchModal(_ref) {
|
|
|
215
226
|
return Object.values(sources).map(function (items, index) {
|
|
216
227
|
return {
|
|
217
228
|
sourceId: "hits".concat(index),
|
|
218
|
-
onSelect: function onSelect(
|
|
219
|
-
var item =
|
|
220
|
-
event =
|
|
229
|
+
onSelect: function onSelect(_ref8) {
|
|
230
|
+
var item = _ref8.item,
|
|
231
|
+
event = _ref8.event;
|
|
221
232
|
saveRecentSearch(item);
|
|
222
233
|
|
|
223
234
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
224
235
|
onClose();
|
|
225
236
|
}
|
|
226
237
|
},
|
|
227
|
-
getItemUrl: function getItemUrl(
|
|
228
|
-
var item =
|
|
238
|
+
getItemUrl: function getItemUrl(_ref9) {
|
|
239
|
+
var item = _ref9.item;
|
|
229
240
|
return item.url;
|
|
230
241
|
},
|
|
231
242
|
getItems: function getItems() {
|
|
232
243
|
return Object.values(groupBy(items, function (item) {
|
|
233
244
|
return item.hierarchy.lvl1;
|
|
234
|
-
})).map(transformItems).map(function (
|
|
235
|
-
return
|
|
245
|
+
})).map(transformItems).map(function (groupedHits) {
|
|
246
|
+
return groupedHits.map(function (item) {
|
|
236
247
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
237
|
-
|
|
238
|
-
__docsearch_parent: item.type !== 'lvl1' && hits.find(function (siblingItem) {
|
|
248
|
+
__docsearch_parent: item.type !== 'lvl1' && groupedHits.find(function (siblingItem) {
|
|
239
249
|
return siblingItem.type === 'lvl1' && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1;
|
|
240
250
|
})
|
|
241
251
|
});
|
|
@@ -320,6 +330,8 @@ export function DocSearchModal(_ref) {
|
|
|
320
330
|
'aria-expanded': true
|
|
321
331
|
}), {
|
|
322
332
|
className: ['DocSearch', 'DocSearch-Container', state.status === 'stalled' && 'DocSearch-Container--Stalled', state.status === 'error' && 'DocSearch-Container--Errored'].filter(Boolean).join(' '),
|
|
333
|
+
role: "button",
|
|
334
|
+
tabIndex: 0,
|
|
323
335
|
onMouseDown: function onMouseDown(event) {
|
|
324
336
|
if (event.target === event.currentTarget) {
|
|
325
337
|
onClose();
|
|
@@ -334,9 +346,10 @@ export function DocSearchModal(_ref) {
|
|
|
334
346
|
}, /*#__PURE__*/React.createElement(SearchBox, _extends({}, autocomplete, {
|
|
335
347
|
state: state,
|
|
336
348
|
autoFocus: initialQuery.length === 0,
|
|
337
|
-
onClose: onClose,
|
|
338
349
|
inputRef: inputRef,
|
|
339
|
-
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection
|
|
350
|
+
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
|
|
351
|
+
translations: searchBoxTranslations,
|
|
352
|
+
onClose: onClose
|
|
340
353
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
341
354
|
className: "DocSearch-Dropdown",
|
|
342
355
|
ref: dropdownRef
|
|
@@ -348,12 +361,16 @@ export function DocSearchModal(_ref) {
|
|
|
348
361
|
disableUserPersonalization: disableUserPersonalization,
|
|
349
362
|
recentSearches: recentSearches,
|
|
350
363
|
favoriteSearches: favoriteSearches,
|
|
364
|
+
inputRef: inputRef,
|
|
365
|
+
translations: screenStateTranslations,
|
|
366
|
+
getMissingResultsUrl: getMissingResultsUrl,
|
|
351
367
|
onItemClick: function onItemClick(item) {
|
|
352
368
|
saveRecentSearch(item);
|
|
353
369
|
onClose();
|
|
354
|
-
}
|
|
355
|
-
inputRef: inputRef
|
|
370
|
+
}
|
|
356
371
|
}))), /*#__PURE__*/React.createElement("footer", {
|
|
357
372
|
className: "DocSearch-Footer"
|
|
358
|
-
}, /*#__PURE__*/React.createElement(Footer,
|
|
373
|
+
}, /*#__PURE__*/React.createElement(Footer, {
|
|
374
|
+
translations: footerTranslations
|
|
375
|
+
}))));
|
|
359
376
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare
|
|
2
|
+
export declare type ErrorScreenTranslations = Partial<{
|
|
3
|
+
titleText: string;
|
|
4
|
+
helpText: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type ErrorScreenProps = {
|
|
7
|
+
translations?: ErrorScreenTranslations;
|
|
8
|
+
};
|
|
9
|
+
export declare function ErrorScreen({ translations }: ErrorScreenProps): JSX.Element;
|
|
10
|
+
export {};
|
package/dist/esm/ErrorScreen.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ErrorIcon } from './icons';
|
|
3
|
-
export function ErrorScreen() {
|
|
3
|
+
export function ErrorScreen(_ref) {
|
|
4
|
+
var _ref$translations = _ref.translations,
|
|
5
|
+
translations = _ref$translations === void 0 ? {} : _ref$translations;
|
|
6
|
+
var _translations$titleTe = translations.titleText,
|
|
7
|
+
titleText = _translations$titleTe === void 0 ? 'Unable to fetch results' : _translations$titleTe,
|
|
8
|
+
_translations$helpTex = translations.helpText,
|
|
9
|
+
helpText = _translations$helpTex === void 0 ? 'You might want to check your network connection.' : _translations$helpTex;
|
|
4
10
|
return /*#__PURE__*/React.createElement("div", {
|
|
5
11
|
className: "DocSearch-ErrorScreen"
|
|
6
12
|
}, /*#__PURE__*/React.createElement("div", {
|
|
7
13
|
className: "DocSearch-Screen-Icon"
|
|
8
14
|
}, /*#__PURE__*/React.createElement(ErrorIcon, null)), /*#__PURE__*/React.createElement("p", {
|
|
9
15
|
className: "DocSearch-Title"
|
|
10
|
-
},
|
|
16
|
+
}, titleText), /*#__PURE__*/React.createElement("p", {
|
|
11
17
|
className: "DocSearch-Help"
|
|
12
|
-
},
|
|
18
|
+
}, helpText));
|
|
13
19
|
}
|
package/dist/esm/Footer.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare
|
|
2
|
+
export declare type FooterTranslations = Partial<{
|
|
3
|
+
selectText: string;
|
|
4
|
+
navigateText: string;
|
|
5
|
+
closeText: string;
|
|
6
|
+
searchByText: string;
|
|
7
|
+
}>;
|
|
8
|
+
declare type FooterProps = Partial<{
|
|
9
|
+
translations: FooterTranslations;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function Footer({ translations }: FooterProps): JSX.Element;
|
|
12
|
+
export {};
|
package/dist/esm/Footer.js
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AlgoliaLogo } from './AlgoliaLogo';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
function CommandIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
6
|
+
width: "15",
|
|
7
|
+
height: "15"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
9
|
+
fill: "none",
|
|
10
|
+
stroke: "currentColor",
|
|
11
|
+
strokeLinecap: "round",
|
|
12
|
+
strokeLinejoin: "round",
|
|
13
|
+
strokeWidth: "1.2"
|
|
14
|
+
}, props.children));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Footer(_ref) {
|
|
18
|
+
var _ref$translations = _ref.translations,
|
|
19
|
+
translations = _ref$translations === void 0 ? {} : _ref$translations;
|
|
20
|
+
var _translations$selectT = translations.selectText,
|
|
21
|
+
selectText = _translations$selectT === void 0 ? 'to select' : _translations$selectT,
|
|
22
|
+
_translations$navigat = translations.navigateText,
|
|
23
|
+
navigateText = _translations$navigat === void 0 ? 'to navigate' : _translations$navigat,
|
|
24
|
+
_translations$closeTe = translations.closeText,
|
|
25
|
+
closeText = _translations$closeTe === void 0 ? 'to close' : _translations$closeTe,
|
|
26
|
+
_translations$searchB = translations.searchByText,
|
|
27
|
+
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
|
|
4
28
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
5
29
|
className: "DocSearch-Logo"
|
|
6
|
-
}, /*#__PURE__*/React.createElement(AlgoliaLogo,
|
|
30
|
+
}, /*#__PURE__*/React.createElement(AlgoliaLogo, {
|
|
31
|
+
translations: {
|
|
32
|
+
searchByText: searchByText
|
|
33
|
+
}
|
|
34
|
+
})), /*#__PURE__*/React.createElement("ul", {
|
|
7
35
|
className: "DocSearch-Commands"
|
|
8
36
|
}, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
|
|
9
37
|
className: "DocSearch-Commands-Key"
|
|
@@ -11,7 +39,7 @@ export function Footer() {
|
|
|
11
39
|
d: "M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"
|
|
12
40
|
}))), /*#__PURE__*/React.createElement("span", {
|
|
13
41
|
className: "DocSearch-Label"
|
|
14
|
-
},
|
|
42
|
+
}, selectText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
|
|
15
43
|
className: "DocSearch-Commands-Key"
|
|
16
44
|
}, /*#__PURE__*/React.createElement(CommandIcon, null, /*#__PURE__*/React.createElement("path", {
|
|
17
45
|
d: "M7.5 3.5v8M10.5 8.5l-3 3-3-3"
|
|
@@ -21,24 +49,11 @@ export function Footer() {
|
|
|
21
49
|
d: "M7.5 11.5v-8M10.5 6.5l-3-3-3 3"
|
|
22
50
|
}))), /*#__PURE__*/React.createElement("span", {
|
|
23
51
|
className: "DocSearch-Label"
|
|
24
|
-
},
|
|
52
|
+
}, navigateText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
|
|
25
53
|
className: "DocSearch-Commands-Key"
|
|
26
54
|
}, /*#__PURE__*/React.createElement(CommandIcon, null, /*#__PURE__*/React.createElement("path", {
|
|
27
55
|
d: "M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956"
|
|
28
56
|
}))), /*#__PURE__*/React.createElement("span", {
|
|
29
57
|
className: "DocSearch-Label"
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function CommandIcon(props) {
|
|
34
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
35
|
-
width: "15",
|
|
36
|
-
height: "15"
|
|
37
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
38
|
-
fill: "none",
|
|
39
|
-
stroke: "currentColor",
|
|
40
|
-
strokeLinecap: "round",
|
|
41
|
-
strokeLinejoin: "round",
|
|
42
|
-
strokeWidth: "1.2"
|
|
43
|
-
}, props.children));
|
|
58
|
+
}, closeText))));
|
|
44
59
|
}
|
package/dist/esm/Hit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
3
3
|
interface HitProps {
|
|
4
|
-
hit:
|
|
4
|
+
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export declare function Hit({ hit, children }: HitProps): JSX.Element;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ScreenStateProps } from './ScreenState';
|
|
3
|
-
import { InternalDocSearchHit } from './types';
|
|
4
|
-
declare type
|
|
5
|
-
|
|
2
|
+
import type { ScreenStateProps } from './ScreenState';
|
|
3
|
+
import type { InternalDocSearchHit } from './types';
|
|
4
|
+
export declare type NoResultsScreenTranslations = Partial<{
|
|
5
|
+
noResultsText: string;
|
|
6
|
+
suggestedQueryText: string;
|
|
7
|
+
reportMissingResultsText: string;
|
|
8
|
+
reportMissingResultsLinkText: string;
|
|
9
|
+
}>;
|
|
10
|
+
declare type NoResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'> & {
|
|
11
|
+
translations?: NoResultsScreenTranslations;
|
|
12
|
+
};
|
|
13
|
+
export declare function NoResultsScreen({ translations, ...props }: NoResultsScreenProps): JSX.Element;
|
|
6
14
|
export {};
|