@docsearch/react 3.0.0-alpha.41 → 3.0.0-alpha.42
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/dist/esm/AlgoliaLogo.d.ts +8 -1
- package/dist/esm/AlgoliaLogo.js +6 -2
- package/dist/esm/DocSearch.d.ts +17 -10
- package/dist/esm/DocSearch.js +7 -3
- 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 +54 -39
- 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 +25 -6
- 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 +16 -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 +7 -4
- package/dist/esm/StartScreen.d.ts +14 -5
- package/dist/esm/StartScreen.js +40 -14
- package/dist/esm/__tests__/api.test.js +224 -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/useDocSearchKeyboardEvents.js +4 -1
- 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/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
|
@@ -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
8
|
href: "https://www.algolia.com/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,31 @@
|
|
|
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;
|
|
23
30
|
}
|
|
24
31
|
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) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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),
|
|
@@ -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, }: DocSearchModalProps): JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
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); if (enumerableOnly)
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
6
|
|
|
5
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
8
|
|
|
@@ -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) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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,13 @@ 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
|
+
|
|
69
|
+
var footerTranslations = translations.footer,
|
|
70
|
+
searchBoxTranslations = translations.searchBox,
|
|
71
|
+
screenStateTranslations = _objectWithoutProperties(translations, _excluded);
|
|
60
72
|
|
|
61
73
|
var _React$useState = React.useState({
|
|
62
74
|
query: '',
|
|
@@ -117,16 +129,14 @@ export function DocSearchModal(_ref) {
|
|
|
117
129
|
}
|
|
118
130
|
},
|
|
119
131
|
navigator: navigator,
|
|
120
|
-
onStateChange: function onStateChange(
|
|
121
|
-
|
|
122
|
-
setState(state);
|
|
132
|
+
onStateChange: function onStateChange(props) {
|
|
133
|
+
setState(props.state);
|
|
123
134
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
setStatus = _ref3.setStatus;
|
|
135
|
+
getSources: function getSources(_ref2) {
|
|
136
|
+
var query = _ref2.query,
|
|
137
|
+
sourcesState = _ref2.state,
|
|
138
|
+
setContext = _ref2.setContext,
|
|
139
|
+
setStatus = _ref2.setStatus;
|
|
130
140
|
|
|
131
141
|
if (!query) {
|
|
132
142
|
if (disableUserPersonalization) {
|
|
@@ -135,17 +145,17 @@ export function DocSearchModal(_ref) {
|
|
|
135
145
|
|
|
136
146
|
return [{
|
|
137
147
|
sourceId: 'recentSearches',
|
|
138
|
-
onSelect: function onSelect(
|
|
139
|
-
var item =
|
|
140
|
-
event =
|
|
148
|
+
onSelect: function onSelect(_ref3) {
|
|
149
|
+
var item = _ref3.item,
|
|
150
|
+
event = _ref3.event;
|
|
141
151
|
saveRecentSearch(item);
|
|
142
152
|
|
|
143
153
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
144
154
|
onClose();
|
|
145
155
|
}
|
|
146
156
|
},
|
|
147
|
-
getItemUrl: function getItemUrl(
|
|
148
|
-
var item =
|
|
157
|
+
getItemUrl: function getItemUrl(_ref4) {
|
|
158
|
+
var item = _ref4.item;
|
|
149
159
|
return item.url;
|
|
150
160
|
},
|
|
151
161
|
getItems: function getItems() {
|
|
@@ -153,17 +163,17 @@ export function DocSearchModal(_ref) {
|
|
|
153
163
|
}
|
|
154
164
|
}, {
|
|
155
165
|
sourceId: 'favoriteSearches',
|
|
156
|
-
onSelect: function onSelect(
|
|
157
|
-
var item =
|
|
158
|
-
event =
|
|
166
|
+
onSelect: function onSelect(_ref5) {
|
|
167
|
+
var item = _ref5.item,
|
|
168
|
+
event = _ref5.event;
|
|
159
169
|
saveRecentSearch(item);
|
|
160
170
|
|
|
161
171
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
162
172
|
onClose();
|
|
163
173
|
}
|
|
164
174
|
},
|
|
165
|
-
getItemUrl: function getItemUrl(
|
|
166
|
-
var item =
|
|
175
|
+
getItemUrl: function getItemUrl(_ref6) {
|
|
176
|
+
var item = _ref6.item;
|
|
167
177
|
return item.url;
|
|
168
178
|
},
|
|
169
179
|
getItems: function getItems() {
|
|
@@ -193,8 +203,8 @@ export function DocSearchModal(_ref) {
|
|
|
193
203
|
}
|
|
194
204
|
|
|
195
205
|
throw error;
|
|
196
|
-
}).then(function (
|
|
197
|
-
var results =
|
|
206
|
+
}).then(function (_ref7) {
|
|
207
|
+
var results = _ref7.results;
|
|
198
208
|
var _results$ = results[0],
|
|
199
209
|
hits = _results$.hits,
|
|
200
210
|
nbHits = _results$.nbHits;
|
|
@@ -203,7 +213,7 @@ export function DocSearchModal(_ref) {
|
|
|
203
213
|
}); // We store the `lvl0`s to display them as search suggestions
|
|
204
214
|
// in the "no results" screen.
|
|
205
215
|
|
|
206
|
-
if (
|
|
216
|
+
if (sourcesState.context.searchSuggestions.length < Object.keys(sources).length) {
|
|
207
217
|
setContext({
|
|
208
218
|
searchSuggestions: Object.keys(sources)
|
|
209
219
|
});
|
|
@@ -215,27 +225,26 @@ export function DocSearchModal(_ref) {
|
|
|
215
225
|
return Object.values(sources).map(function (items, index) {
|
|
216
226
|
return {
|
|
217
227
|
sourceId: "hits".concat(index),
|
|
218
|
-
onSelect: function onSelect(
|
|
219
|
-
var item =
|
|
220
|
-
event =
|
|
228
|
+
onSelect: function onSelect(_ref8) {
|
|
229
|
+
var item = _ref8.item,
|
|
230
|
+
event = _ref8.event;
|
|
221
231
|
saveRecentSearch(item);
|
|
222
232
|
|
|
223
233
|
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
224
234
|
onClose();
|
|
225
235
|
}
|
|
226
236
|
},
|
|
227
|
-
getItemUrl: function getItemUrl(
|
|
228
|
-
var item =
|
|
237
|
+
getItemUrl: function getItemUrl(_ref9) {
|
|
238
|
+
var item = _ref9.item;
|
|
229
239
|
return item.url;
|
|
230
240
|
},
|
|
231
241
|
getItems: function getItems() {
|
|
232
242
|
return Object.values(groupBy(items, function (item) {
|
|
233
243
|
return item.hierarchy.lvl1;
|
|
234
|
-
})).map(transformItems).map(function (
|
|
235
|
-
return
|
|
244
|
+
})).map(transformItems).map(function (groupedHits) {
|
|
245
|
+
return groupedHits.map(function (item) {
|
|
236
246
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
237
|
-
|
|
238
|
-
__docsearch_parent: item.type !== 'lvl1' && hits.find(function (siblingItem) {
|
|
247
|
+
__docsearch_parent: item.type !== 'lvl1' && groupedHits.find(function (siblingItem) {
|
|
239
248
|
return siblingItem.type === 'lvl1' && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1;
|
|
240
249
|
})
|
|
241
250
|
});
|
|
@@ -320,6 +329,8 @@ export function DocSearchModal(_ref) {
|
|
|
320
329
|
'aria-expanded': true
|
|
321
330
|
}), {
|
|
322
331
|
className: ['DocSearch', 'DocSearch-Container', state.status === 'stalled' && 'DocSearch-Container--Stalled', state.status === 'error' && 'DocSearch-Container--Errored'].filter(Boolean).join(' '),
|
|
332
|
+
role: "button",
|
|
333
|
+
tabIndex: 0,
|
|
323
334
|
onMouseDown: function onMouseDown(event) {
|
|
324
335
|
if (event.target === event.currentTarget) {
|
|
325
336
|
onClose();
|
|
@@ -334,9 +345,10 @@ export function DocSearchModal(_ref) {
|
|
|
334
345
|
}, /*#__PURE__*/React.createElement(SearchBox, _extends({}, autocomplete, {
|
|
335
346
|
state: state,
|
|
336
347
|
autoFocus: initialQuery.length === 0,
|
|
337
|
-
onClose: onClose,
|
|
338
348
|
inputRef: inputRef,
|
|
339
|
-
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection
|
|
349
|
+
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
|
|
350
|
+
translations: searchBoxTranslations,
|
|
351
|
+
onClose: onClose
|
|
340
352
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
341
353
|
className: "DocSearch-Dropdown",
|
|
342
354
|
ref: dropdownRef
|
|
@@ -348,12 +360,15 @@ export function DocSearchModal(_ref) {
|
|
|
348
360
|
disableUserPersonalization: disableUserPersonalization,
|
|
349
361
|
recentSearches: recentSearches,
|
|
350
362
|
favoriteSearches: favoriteSearches,
|
|
363
|
+
inputRef: inputRef,
|
|
364
|
+
translations: screenStateTranslations,
|
|
351
365
|
onItemClick: function onItemClick(item) {
|
|
352
366
|
saveRecentSearch(item);
|
|
353
367
|
onClose();
|
|
354
|
-
}
|
|
355
|
-
inputRef: inputRef
|
|
368
|
+
}
|
|
356
369
|
}))), /*#__PURE__*/React.createElement("footer", {
|
|
357
370
|
className: "DocSearch-Footer"
|
|
358
|
-
}, /*#__PURE__*/React.createElement(Footer,
|
|
371
|
+
}, /*#__PURE__*/React.createElement(Footer, {
|
|
372
|
+
translations: footerTranslations
|
|
373
|
+
}))));
|
|
359
374
|
}
|
|
@@ -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
|
+
openIssueText: string;
|
|
8
|
+
openIssueLinkText: 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 {};
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
+
var _excluded = ["translations"];
|
|
2
|
+
|
|
1
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
4
|
|
|
3
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
6
|
|
|
5
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
8
|
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" &&
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
8
10
|
|
|
9
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
12
|
|
|
11
13
|
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; }
|
|
12
14
|
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
13
19
|
import React from 'react';
|
|
14
20
|
import { NoResultsIcon } from './icons';
|
|
15
|
-
export function NoResultsScreen(
|
|
21
|
+
export function NoResultsScreen(_ref) {
|
|
22
|
+
var _ref$translations = _ref.translations,
|
|
23
|
+
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
|
|
26
|
+
var _translations$noResul = translations.noResultsText,
|
|
27
|
+
noResultsText = _translations$noResul === void 0 ? 'No results for' : _translations$noResul,
|
|
28
|
+
_translations$suggest = translations.suggestedQueryText,
|
|
29
|
+
suggestedQueryText = _translations$suggest === void 0 ? 'Try searching for' : _translations$suggest,
|
|
30
|
+
_translations$openIss = translations.openIssueText,
|
|
31
|
+
openIssueText = _translations$openIss === void 0 ? 'Believe this query should return results?' : _translations$openIss,
|
|
32
|
+
_translations$openIss2 = translations.openIssueLinkText,
|
|
33
|
+
openIssueLinkText = _translations$openIss2 === void 0 ? 'Let us know' : _translations$openIss2;
|
|
16
34
|
var searchSuggestions = props.state.context.searchSuggestions;
|
|
17
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
36
|
className: "DocSearch-NoResults"
|
|
@@ -20,16 +38,17 @@ export function NoResultsScreen(props) {
|
|
|
20
38
|
className: "DocSearch-Screen-Icon"
|
|
21
39
|
}, /*#__PURE__*/React.createElement(NoResultsIcon, null)), /*#__PURE__*/React.createElement("p", {
|
|
22
40
|
className: "DocSearch-Title"
|
|
23
|
-
}, "
|
|
41
|
+
}, noResultsText, " \"", /*#__PURE__*/React.createElement("strong", null, props.state.query), "\""), searchSuggestions && searchSuggestions.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
24
42
|
className: "DocSearch-NoResults-Prefill-List"
|
|
25
43
|
}, /*#__PURE__*/React.createElement("p", {
|
|
26
44
|
className: "DocSearch-Help"
|
|
27
|
-
}, "
|
|
45
|
+
}, suggestedQueryText, ":"), /*#__PURE__*/React.createElement("ul", null, searchSuggestions.slice(0, 3).reduce(function (acc, search) {
|
|
28
46
|
return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement("li", {
|
|
29
47
|
key: search
|
|
30
48
|
}, /*#__PURE__*/React.createElement("button", {
|
|
31
49
|
className: "DocSearch-Prefill",
|
|
32
50
|
key: search,
|
|
51
|
+
type: "button",
|
|
33
52
|
onClick: function onClick() {
|
|
34
53
|
props.setQuery(search.toLowerCase() + ' ');
|
|
35
54
|
props.refresh();
|
|
@@ -38,9 +57,9 @@ export function NoResultsScreen(props) {
|
|
|
38
57
|
}, search))]);
|
|
39
58
|
}, []))), /*#__PURE__*/React.createElement("p", {
|
|
40
59
|
className: "DocSearch-Help"
|
|
41
|
-
}, "
|
|
60
|
+
}, "".concat(openIssueText, " "), /*#__PURE__*/React.createElement("a", {
|
|
42
61
|
href: "https://github.com/algolia/docsearch-configs/issues/new?template=Missing_results.md&title=[".concat(props.indexName, "]+Missing+results+for+query+\"").concat(props.state.query, "\""),
|
|
43
62
|
target: "_blank",
|
|
44
63
|
rel: "noopener noreferrer"
|
|
45
|
-
},
|
|
64
|
+
}, openIssueLinkText), "."));
|
|
46
65
|
}
|