@docsearch/react 3.6.0 → 3.6.1
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/button.js +1 -1
- package/dist/esm/index.d.ts +195 -5
- package/dist/esm/index.js +1 -5
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/modal.js +1 -1
- package/package.json +6 -7
- package/dist/esm/AlgoliaLogo.d.ts +0 -8
- package/dist/esm/AlgoliaLogo.js +0 -54
- package/dist/esm/DocSearch.d.ts +0 -36
- package/dist/esm/DocSearch.js +0 -62
- package/dist/esm/DocSearchButton.d.ts +0 -9
- package/dist/esm/DocSearchButton.js +0 -109
- package/dist/esm/DocSearchModal.d.ts +0 -14
- package/dist/esm/DocSearchModal.js +0 -418
- package/dist/esm/ErrorScreen.d.ts +0 -9
- package/dist/esm/ErrorScreen.js +0 -19
- package/dist/esm/Footer.d.ts +0 -15
- package/dist/esm/Footer.js +0 -77
- package/dist/esm/Hit.d.ts +0 -8
- package/dist/esm/Hit.js +0 -8
- package/dist/esm/NoResultsScreen.d.ts +0 -13
- package/dist/esm/NoResultsScreen.js +0 -67
- package/dist/esm/Results.d.ts +0 -21
- package/dist/esm/Results.js +0 -123
- package/dist/esm/ResultsScreen.d.ts +0 -5
- package/dist/esm/ResultsScreen.js +0 -55
- package/dist/esm/ScreenState.d.ts +0 -27
- package/dist/esm/ScreenState.js +0 -49
- package/dist/esm/SearchBox.d.ts +0 -21
- package/dist/esm/SearchBox.js +0 -76
- package/dist/esm/Snippet.d.ts +0 -14
- package/dist/esm/Snippet.js +0 -35
- package/dist/esm/StartScreen.d.ts +0 -16
- package/dist/esm/StartScreen.js +0 -119
- package/dist/esm/__tests__/api.test.js +0 -460
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/icons/ControlKeyIcon.d.ts +0 -1
- package/dist/esm/icons/ControlKeyIcon.js +0 -14
- package/dist/esm/icons/ErrorIcon.d.ts +0 -1
- package/dist/esm/icons/ErrorIcon.js +0 -15
- package/dist/esm/icons/GoToExternalIcon.d.ts +0 -1
- package/dist/esm/icons/GoToExternalIcon.js +0 -11
- package/dist/esm/icons/LoadingIcon.d.ts +0 -1
- package/dist/esm/icons/LoadingIcon.js +0 -28
- package/dist/esm/icons/NoResultsIcon.d.ts +0 -1
- package/dist/esm/icons/NoResultsIcon.js +0 -15
- package/dist/esm/icons/RecentIcon.d.ts +0 -1
- package/dist/esm/icons/RecentIcon.js +0 -18
- package/dist/esm/icons/ResetIcon.d.ts +0 -1
- package/dist/esm/icons/ResetIcon.js +0 -15
- package/dist/esm/icons/SearchIcon.d.ts +0 -1
- package/dist/esm/icons/SearchIcon.js +0 -17
- package/dist/esm/icons/SelectIcon.d.ts +0 -1
- package/dist/esm/icons/SelectIcon.js +0 -19
- package/dist/esm/icons/SourceIcon.d.ts +0 -3
- package/dist/esm/icons/SourceIcon.js +0 -57
- package/dist/esm/icons/StarIcon.d.ts +0 -1
- package/dist/esm/icons/StarIcon.js +0 -14
- package/dist/esm/icons/index.d.ts +0 -10
- package/dist/esm/icons/index.js +0 -10
- package/dist/esm/stored-searches.d.ts +0 -12
- package/dist/esm/stored-searches.js +0 -75
- package/dist/esm/types/DocSearchHit.d.ts +0 -75
- package/dist/esm/types/DocSearchHit.js +0 -1
- package/dist/esm/types/DocSearchState.d.ts +0 -10
- package/dist/esm/types/DocSearchState.js +0 -1
- package/dist/esm/types/InternalDocSearchHit.d.ts +0 -4
- package/dist/esm/types/InternalDocSearchHit.js +0 -1
- package/dist/esm/types/StoredDocSearchHit.d.ts +0 -2
- package/dist/esm/types/StoredDocSearchHit.js +0 -1
- package/dist/esm/types/index.d.ts +0 -4
- package/dist/esm/types/index.js +0 -4
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +0 -9
- package/dist/esm/useDocSearchKeyboardEvents.js +0 -55
- package/dist/esm/useSearchClient.d.ts +0 -2
- package/dist/esm/useSearchClient.js +0 -20
- package/dist/esm/useTouchEvents.d.ts +0 -9
- package/dist/esm/useTouchEvents.js +0 -27
- package/dist/esm/useTrapFocus.d.ts +0 -5
- package/dist/esm/useTrapFocus.js +0 -34
- package/dist/esm/utils/groupBy.d.ts +0 -1
- package/dist/esm/utils/groupBy.js +0 -17
- package/dist/esm/utils/identity.d.ts +0 -1
- package/dist/esm/utils/identity.js +0 -3
- package/dist/esm/utils/index.d.ts +0 -5
- package/dist/esm/utils/index.js +0 -5
- package/dist/esm/utils/isModifierEvent.d.ts +0 -5
- package/dist/esm/utils/isModifierEvent.js +0 -8
- package/dist/esm/utils/noop.d.ts +0 -1
- package/dist/esm/utils/noop.js +0 -1
- package/dist/esm/utils/removeHighlightTags.d.ts +0 -2
- package/dist/esm/utils/removeHighlightTags.js +0 -16
- package/dist/esm/version.d.ts +0 -1
- package/dist/esm/version.js +0 -1
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
var _excluded = ["footer", "searchBox"];
|
|
2
|
-
|
|
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); }
|
|
4
|
-
|
|
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; }
|
|
6
|
-
|
|
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; }
|
|
8
|
-
|
|
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; }
|
|
10
|
-
|
|
11
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
-
|
|
13
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
-
|
|
15
|
-
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); }
|
|
16
|
-
|
|
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; }
|
|
18
|
-
|
|
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; }
|
|
20
|
-
|
|
21
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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
|
-
|
|
27
|
-
import { createAutocomplete } from '@algolia/autocomplete-core';
|
|
28
|
-
import React from 'react';
|
|
29
|
-
import { MAX_QUERY_SIZE } from './constants';
|
|
30
|
-
import { Footer } from './Footer';
|
|
31
|
-
import { Hit } from './Hit';
|
|
32
|
-
import { ScreenState } from './ScreenState';
|
|
33
|
-
import { SearchBox } from './SearchBox';
|
|
34
|
-
import { createStoredSearches } from './stored-searches';
|
|
35
|
-
import { useSearchClient } from './useSearchClient';
|
|
36
|
-
import { useTouchEvents } from './useTouchEvents';
|
|
37
|
-
import { useTrapFocus } from './useTrapFocus';
|
|
38
|
-
import { groupBy, identity, noop, removeHighlightTags, isModifierEvent } from './utils';
|
|
39
|
-
export function DocSearchModal(_ref) {
|
|
40
|
-
var appId = _ref.appId,
|
|
41
|
-
apiKey = _ref.apiKey,
|
|
42
|
-
indexName = _ref.indexName,
|
|
43
|
-
_ref$placeholder = _ref.placeholder,
|
|
44
|
-
placeholder = _ref$placeholder === void 0 ? 'Search docs' : _ref$placeholder,
|
|
45
|
-
searchParameters = _ref.searchParameters,
|
|
46
|
-
maxResultsPerGroup = _ref.maxResultsPerGroup,
|
|
47
|
-
_ref$onClose = _ref.onClose,
|
|
48
|
-
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
49
|
-
_ref$transformItems = _ref.transformItems,
|
|
50
|
-
transformItems = _ref$transformItems === void 0 ? identity : _ref$transformItems,
|
|
51
|
-
_ref$hitComponent = _ref.hitComponent,
|
|
52
|
-
hitComponent = _ref$hitComponent === void 0 ? Hit : _ref$hitComponent,
|
|
53
|
-
_ref$resultsFooterCom = _ref.resultsFooterComponent,
|
|
54
|
-
resultsFooterComponent = _ref$resultsFooterCom === void 0 ? function () {
|
|
55
|
-
return null;
|
|
56
|
-
} : _ref$resultsFooterCom,
|
|
57
|
-
navigator = _ref.navigator,
|
|
58
|
-
_ref$initialScrollY = _ref.initialScrollY,
|
|
59
|
-
initialScrollY = _ref$initialScrollY === void 0 ? 0 : _ref$initialScrollY,
|
|
60
|
-
_ref$transformSearchC = _ref.transformSearchClient,
|
|
61
|
-
transformSearchClient = _ref$transformSearchC === void 0 ? identity : _ref$transformSearchC,
|
|
62
|
-
_ref$disableUserPerso = _ref.disableUserPersonalization,
|
|
63
|
-
disableUserPersonalization = _ref$disableUserPerso === void 0 ? false : _ref$disableUserPerso,
|
|
64
|
-
_ref$initialQuery = _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
|
-
_ref$insights = _ref.insights,
|
|
70
|
-
insights = _ref$insights === void 0 ? false : _ref$insights;
|
|
71
|
-
|
|
72
|
-
var footerTranslations = translations.footer,
|
|
73
|
-
searchBoxTranslations = translations.searchBox,
|
|
74
|
-
screenStateTranslations = _objectWithoutProperties(translations, _excluded);
|
|
75
|
-
|
|
76
|
-
var _React$useState = React.useState({
|
|
77
|
-
query: '',
|
|
78
|
-
collections: [],
|
|
79
|
-
completion: null,
|
|
80
|
-
context: {},
|
|
81
|
-
isOpen: false,
|
|
82
|
-
activeItemId: null,
|
|
83
|
-
status: 'idle'
|
|
84
|
-
}),
|
|
85
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
86
|
-
state = _React$useState2[0],
|
|
87
|
-
setState = _React$useState2[1];
|
|
88
|
-
|
|
89
|
-
var containerRef = React.useRef(null);
|
|
90
|
-
var modalRef = React.useRef(null);
|
|
91
|
-
var formElementRef = React.useRef(null);
|
|
92
|
-
var dropdownRef = React.useRef(null);
|
|
93
|
-
var inputRef = React.useRef(null);
|
|
94
|
-
var snippetLength = React.useRef(10);
|
|
95
|
-
var initialQueryFromSelection = React.useRef(typeof window !== 'undefined' ? window.getSelection().toString().slice(0, MAX_QUERY_SIZE) : '').current;
|
|
96
|
-
var initialQuery = React.useRef(initialQueryFromProp || initialQueryFromSelection).current;
|
|
97
|
-
var searchClient = useSearchClient(appId, apiKey, transformSearchClient);
|
|
98
|
-
var favoriteSearches = React.useRef(createStoredSearches({
|
|
99
|
-
key: "__DOCSEARCH_FAVORITE_SEARCHES__".concat(indexName),
|
|
100
|
-
limit: 10
|
|
101
|
-
})).current;
|
|
102
|
-
var recentSearches = React.useRef(createStoredSearches({
|
|
103
|
-
key: "__DOCSEARCH_RECENT_SEARCHES__".concat(indexName),
|
|
104
|
-
// We display 7 recent searches and there's no favorites, but only
|
|
105
|
-
// 4 when there are favorites.
|
|
106
|
-
limit: favoriteSearches.getAll().length === 0 ? 7 : 4
|
|
107
|
-
})).current;
|
|
108
|
-
var saveRecentSearch = React.useCallback(function saveRecentSearch(item) {
|
|
109
|
-
if (disableUserPersonalization) {
|
|
110
|
-
return;
|
|
111
|
-
} // We don't store `content` record, but their parent if available.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var search = item.type === 'content' ? item.__docsearch_parent : item; // We save the recent search only if it's not favorited.
|
|
115
|
-
|
|
116
|
-
if (search && favoriteSearches.getAll().findIndex(function (x) {
|
|
117
|
-
return x.objectID === search.objectID;
|
|
118
|
-
}) === -1) {
|
|
119
|
-
recentSearches.add(search);
|
|
120
|
-
}
|
|
121
|
-
}, [favoriteSearches, recentSearches, disableUserPersonalization]);
|
|
122
|
-
var sendItemClickEvent = React.useCallback(function (item) {
|
|
123
|
-
if (!state.context.algoliaInsightsPlugin || !item.__autocomplete_id) return;
|
|
124
|
-
var insightsItem = item;
|
|
125
|
-
var insightsClickParams = {
|
|
126
|
-
eventName: 'Item Selected',
|
|
127
|
-
index: insightsItem.__autocomplete_indexName,
|
|
128
|
-
items: [insightsItem],
|
|
129
|
-
positions: [item.__autocomplete_id],
|
|
130
|
-
queryID: insightsItem.__autocomplete_queryID
|
|
131
|
-
};
|
|
132
|
-
state.context.algoliaInsightsPlugin.insights.clickedObjectIDsAfterSearch(insightsClickParams);
|
|
133
|
-
}, [state.context.algoliaInsightsPlugin]);
|
|
134
|
-
var autocomplete = React.useMemo(function () {
|
|
135
|
-
return createAutocomplete({
|
|
136
|
-
id: 'docsearch',
|
|
137
|
-
defaultActiveItemId: 0,
|
|
138
|
-
placeholder: placeholder,
|
|
139
|
-
openOnFocus: true,
|
|
140
|
-
initialState: {
|
|
141
|
-
query: initialQuery,
|
|
142
|
-
context: {
|
|
143
|
-
searchSuggestions: []
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
insights: insights,
|
|
147
|
-
navigator: navigator,
|
|
148
|
-
onStateChange: function onStateChange(props) {
|
|
149
|
-
setState(props.state);
|
|
150
|
-
},
|
|
151
|
-
getSources: function getSources(_ref2) {
|
|
152
|
-
var query = _ref2.query,
|
|
153
|
-
sourcesState = _ref2.state,
|
|
154
|
-
setContext = _ref2.setContext,
|
|
155
|
-
setStatus = _ref2.setStatus;
|
|
156
|
-
|
|
157
|
-
if (!query) {
|
|
158
|
-
if (disableUserPersonalization) {
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return [{
|
|
163
|
-
sourceId: 'recentSearches',
|
|
164
|
-
onSelect: function onSelect(_ref3) {
|
|
165
|
-
var item = _ref3.item,
|
|
166
|
-
event = _ref3.event;
|
|
167
|
-
saveRecentSearch(item);
|
|
168
|
-
|
|
169
|
-
if (!isModifierEvent(event)) {
|
|
170
|
-
onClose();
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
getItemUrl: function getItemUrl(_ref4) {
|
|
174
|
-
var item = _ref4.item;
|
|
175
|
-
return item.url;
|
|
176
|
-
},
|
|
177
|
-
getItems: function getItems() {
|
|
178
|
-
return recentSearches.getAll();
|
|
179
|
-
}
|
|
180
|
-
}, {
|
|
181
|
-
sourceId: 'favoriteSearches',
|
|
182
|
-
onSelect: function onSelect(_ref5) {
|
|
183
|
-
var item = _ref5.item,
|
|
184
|
-
event = _ref5.event;
|
|
185
|
-
saveRecentSearch(item);
|
|
186
|
-
|
|
187
|
-
if (!isModifierEvent(event)) {
|
|
188
|
-
onClose();
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
getItemUrl: function getItemUrl(_ref6) {
|
|
192
|
-
var item = _ref6.item;
|
|
193
|
-
return item.url;
|
|
194
|
-
},
|
|
195
|
-
getItems: function getItems() {
|
|
196
|
-
return favoriteSearches.getAll();
|
|
197
|
-
}
|
|
198
|
-
}];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
var insightsActive = Boolean(insights);
|
|
202
|
-
return searchClient.search([{
|
|
203
|
-
query: query,
|
|
204
|
-
indexName: indexName,
|
|
205
|
-
params: _objectSpread({
|
|
206
|
-
attributesToRetrieve: ['hierarchy.lvl0', 'hierarchy.lvl1', 'hierarchy.lvl2', 'hierarchy.lvl3', 'hierarchy.lvl4', 'hierarchy.lvl5', 'hierarchy.lvl6', 'content', 'type', 'url'],
|
|
207
|
-
attributesToSnippet: ["hierarchy.lvl1:".concat(snippetLength.current), "hierarchy.lvl2:".concat(snippetLength.current), "hierarchy.lvl3:".concat(snippetLength.current), "hierarchy.lvl4:".concat(snippetLength.current), "hierarchy.lvl5:".concat(snippetLength.current), "hierarchy.lvl6:".concat(snippetLength.current), "content:".concat(snippetLength.current)],
|
|
208
|
-
snippetEllipsisText: '…',
|
|
209
|
-
highlightPreTag: '<mark>',
|
|
210
|
-
highlightPostTag: '</mark>',
|
|
211
|
-
hitsPerPage: 20,
|
|
212
|
-
clickAnalytics: insightsActive
|
|
213
|
-
}, searchParameters)
|
|
214
|
-
}]).catch(function (error) {
|
|
215
|
-
// The Algolia `RetryError` happens when all the servers have
|
|
216
|
-
// failed, meaning that there's no chance the response comes
|
|
217
|
-
// back. This is the right time to display an error.
|
|
218
|
-
// See https://github.com/algolia/algoliasearch-client-javascript/blob/2ffddf59bc765cd1b664ee0346b28f00229d6e12/packages/transporter/src/errors/createRetryError.ts#L5
|
|
219
|
-
if (error.name === 'RetryError') {
|
|
220
|
-
setStatus('error');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
throw error;
|
|
224
|
-
}).then(function (_ref7) {
|
|
225
|
-
var results = _ref7.results;
|
|
226
|
-
var firstResult = results[0];
|
|
227
|
-
var hits = firstResult.hits,
|
|
228
|
-
nbHits = firstResult.nbHits;
|
|
229
|
-
var sources = groupBy(hits, function (hit) {
|
|
230
|
-
return removeHighlightTags(hit);
|
|
231
|
-
}, maxResultsPerGroup); // We store the `lvl0`s to display them as search suggestions
|
|
232
|
-
// in the "no results" screen.
|
|
233
|
-
|
|
234
|
-
if (sourcesState.context.searchSuggestions.length < Object.keys(sources).length) {
|
|
235
|
-
setContext({
|
|
236
|
-
searchSuggestions: Object.keys(sources)
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
setContext({
|
|
241
|
-
nbHits: nbHits
|
|
242
|
-
});
|
|
243
|
-
var insightsParams = {};
|
|
244
|
-
|
|
245
|
-
if (insightsActive) {
|
|
246
|
-
insightsParams = {
|
|
247
|
-
__autocomplete_indexName: indexName,
|
|
248
|
-
__autocomplete_queryID: firstResult.queryID,
|
|
249
|
-
__autocomplete_algoliaCredentials: {
|
|
250
|
-
appId: appId,
|
|
251
|
-
apiKey: apiKey
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return Object.values(sources).map(function (items, index) {
|
|
257
|
-
return {
|
|
258
|
-
sourceId: "hits".concat(index),
|
|
259
|
-
onSelect: function onSelect(_ref8) {
|
|
260
|
-
var item = _ref8.item,
|
|
261
|
-
event = _ref8.event;
|
|
262
|
-
saveRecentSearch(item);
|
|
263
|
-
|
|
264
|
-
if (!isModifierEvent(event)) {
|
|
265
|
-
onClose();
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
getItemUrl: function getItemUrl(_ref9) {
|
|
269
|
-
var item = _ref9.item;
|
|
270
|
-
return item.url;
|
|
271
|
-
},
|
|
272
|
-
getItems: function getItems() {
|
|
273
|
-
return Object.values(groupBy(items, function (item) {
|
|
274
|
-
return item.hierarchy.lvl1;
|
|
275
|
-
}, maxResultsPerGroup)).map(transformItems).map(function (groupedHits) {
|
|
276
|
-
return groupedHits.map(function (item) {
|
|
277
|
-
var parent = null;
|
|
278
|
-
var potentialParent = groupedHits.find(function (siblingItem) {
|
|
279
|
-
return siblingItem.type === 'lvl1' && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1;
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
if (item.type !== 'lvl1' && potentialParent) {
|
|
283
|
-
parent = potentialParent;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
287
|
-
__docsearch_parent: parent
|
|
288
|
-
}, insightsParams);
|
|
289
|
-
});
|
|
290
|
-
}).flat();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}, [indexName, searchParameters, maxResultsPerGroup, searchClient, onClose, recentSearches, favoriteSearches, saveRecentSearch, initialQuery, placeholder, navigator, transformItems, disableUserPersonalization, insights, appId, apiKey]);
|
|
298
|
-
var getEnvironmentProps = autocomplete.getEnvironmentProps,
|
|
299
|
-
getRootProps = autocomplete.getRootProps,
|
|
300
|
-
refresh = autocomplete.refresh;
|
|
301
|
-
useTouchEvents({
|
|
302
|
-
getEnvironmentProps: getEnvironmentProps,
|
|
303
|
-
panelElement: dropdownRef.current,
|
|
304
|
-
formElement: formElementRef.current,
|
|
305
|
-
inputElement: inputRef.current
|
|
306
|
-
});
|
|
307
|
-
useTrapFocus({
|
|
308
|
-
container: containerRef.current
|
|
309
|
-
});
|
|
310
|
-
React.useEffect(function () {
|
|
311
|
-
document.body.classList.add('DocSearch--active');
|
|
312
|
-
return function () {
|
|
313
|
-
var _window$scrollTo, _window;
|
|
314
|
-
|
|
315
|
-
document.body.classList.remove('DocSearch--active'); // IE11 doesn't support `scrollTo` so we check that the method exists
|
|
316
|
-
// first.
|
|
317
|
-
|
|
318
|
-
(_window$scrollTo = (_window = window).scrollTo) === null || _window$scrollTo === void 0 || _window$scrollTo.call(_window, 0, initialScrollY);
|
|
319
|
-
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
320
|
-
}, []);
|
|
321
|
-
React.useEffect(function () {
|
|
322
|
-
var isMobileMediaQuery = window.matchMedia('(max-width: 768px)');
|
|
323
|
-
|
|
324
|
-
if (isMobileMediaQuery.matches) {
|
|
325
|
-
snippetLength.current = 5;
|
|
326
|
-
}
|
|
327
|
-
}, []);
|
|
328
|
-
React.useEffect(function () {
|
|
329
|
-
if (dropdownRef.current) {
|
|
330
|
-
dropdownRef.current.scrollTop = 0;
|
|
331
|
-
}
|
|
332
|
-
}, [state.query]); // We don't focus the input when there's an initial query (i.e. Selection
|
|
333
|
-
// Search) because users rather want to see the results directly, without the
|
|
334
|
-
// keyboard appearing.
|
|
335
|
-
// We therefore need to refresh the autocomplete instance to load all the
|
|
336
|
-
// results, which is usually triggered on focus.
|
|
337
|
-
|
|
338
|
-
React.useEffect(function () {
|
|
339
|
-
if (initialQuery.length > 0) {
|
|
340
|
-
refresh();
|
|
341
|
-
|
|
342
|
-
if (inputRef.current) {
|
|
343
|
-
inputRef.current.focus();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}, [initialQuery, refresh]); // We rely on a CSS property to set the modal height to the full viewport height
|
|
347
|
-
// because all mobile browsers don't compute their height the same way.
|
|
348
|
-
// See https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
349
|
-
|
|
350
|
-
React.useEffect(function () {
|
|
351
|
-
function setFullViewportHeight() {
|
|
352
|
-
if (modalRef.current) {
|
|
353
|
-
var vh = window.innerHeight * 0.01;
|
|
354
|
-
modalRef.current.style.setProperty('--docsearch-vh', "".concat(vh, "px"));
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
setFullViewportHeight();
|
|
359
|
-
window.addEventListener('resize', setFullViewportHeight);
|
|
360
|
-
return function () {
|
|
361
|
-
window.removeEventListener('resize', setFullViewportHeight);
|
|
362
|
-
};
|
|
363
|
-
}, []);
|
|
364
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
365
|
-
ref: containerRef
|
|
366
|
-
}, getRootProps({
|
|
367
|
-
'aria-expanded': true
|
|
368
|
-
}), {
|
|
369
|
-
className: ['DocSearch', 'DocSearch-Container', state.status === 'stalled' && 'DocSearch-Container--Stalled', state.status === 'error' && 'DocSearch-Container--Errored'].filter(Boolean).join(' '),
|
|
370
|
-
role: "button",
|
|
371
|
-
tabIndex: 0,
|
|
372
|
-
onMouseDown: function onMouseDown(event) {
|
|
373
|
-
if (event.target === event.currentTarget) {
|
|
374
|
-
onClose();
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
378
|
-
className: "DocSearch-Modal",
|
|
379
|
-
ref: modalRef
|
|
380
|
-
}, /*#__PURE__*/React.createElement("header", {
|
|
381
|
-
className: "DocSearch-SearchBar",
|
|
382
|
-
ref: formElementRef
|
|
383
|
-
}, /*#__PURE__*/React.createElement(SearchBox, _extends({}, autocomplete, {
|
|
384
|
-
state: state,
|
|
385
|
-
autoFocus: initialQuery.length === 0,
|
|
386
|
-
inputRef: inputRef,
|
|
387
|
-
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
|
|
388
|
-
translations: searchBoxTranslations,
|
|
389
|
-
onClose: onClose
|
|
390
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
391
|
-
className: "DocSearch-Dropdown",
|
|
392
|
-
ref: dropdownRef
|
|
393
|
-
}, /*#__PURE__*/React.createElement(ScreenState, _extends({}, autocomplete, {
|
|
394
|
-
indexName: indexName,
|
|
395
|
-
state: state,
|
|
396
|
-
hitComponent: hitComponent,
|
|
397
|
-
resultsFooterComponent: resultsFooterComponent,
|
|
398
|
-
disableUserPersonalization: disableUserPersonalization,
|
|
399
|
-
recentSearches: recentSearches,
|
|
400
|
-
favoriteSearches: favoriteSearches,
|
|
401
|
-
inputRef: inputRef,
|
|
402
|
-
translations: screenStateTranslations,
|
|
403
|
-
getMissingResultsUrl: getMissingResultsUrl,
|
|
404
|
-
onItemClick: function onItemClick(item, event) {
|
|
405
|
-
// If insights is active, send insights click event
|
|
406
|
-
sendItemClickEvent(item);
|
|
407
|
-
saveRecentSearch(item);
|
|
408
|
-
|
|
409
|
-
if (!isModifierEvent(event)) {
|
|
410
|
-
onClose();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}))), /*#__PURE__*/React.createElement("footer", {
|
|
414
|
-
className: "DocSearch-Footer"
|
|
415
|
-
}, /*#__PURE__*/React.createElement(Footer, {
|
|
416
|
-
translations: footerTranslations
|
|
417
|
-
}))));
|
|
418
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare type ErrorScreenTranslations = Partial<{
|
|
2
|
-
titleText: string;
|
|
3
|
-
helpText: string;
|
|
4
|
-
}>;
|
|
5
|
-
declare type ErrorScreenProps = {
|
|
6
|
-
translations?: ErrorScreenTranslations;
|
|
7
|
-
};
|
|
8
|
-
export declare function ErrorScreen({ translations }: ErrorScreenProps): JSX.Element;
|
|
9
|
-
export {};
|
package/dist/esm/ErrorScreen.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ErrorIcon } from './icons';
|
|
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;
|
|
10
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
-
className: "DocSearch-ErrorScreen"
|
|
12
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
-
className: "DocSearch-Screen-Icon"
|
|
14
|
-
}, /*#__PURE__*/React.createElement(ErrorIcon, null)), /*#__PURE__*/React.createElement("p", {
|
|
15
|
-
className: "DocSearch-Title"
|
|
16
|
-
}, titleText), /*#__PURE__*/React.createElement("p", {
|
|
17
|
-
className: "DocSearch-Help"
|
|
18
|
-
}, helpText));
|
|
19
|
-
}
|
package/dist/esm/Footer.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare type FooterTranslations = Partial<{
|
|
2
|
-
selectText: string;
|
|
3
|
-
selectKeyAriaLabel: string;
|
|
4
|
-
navigateText: string;
|
|
5
|
-
navigateUpKeyAriaLabel: string;
|
|
6
|
-
navigateDownKeyAriaLabel: string;
|
|
7
|
-
closeText: string;
|
|
8
|
-
closeKeyAriaLabel: string;
|
|
9
|
-
searchByText: string;
|
|
10
|
-
}>;
|
|
11
|
-
declare type FooterProps = Partial<{
|
|
12
|
-
translations: FooterTranslations;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function Footer({ translations }: FooterProps): JSX.Element;
|
|
15
|
-
export {};
|
package/dist/esm/Footer.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { AlgoliaLogo } from './AlgoliaLogo';
|
|
3
|
-
|
|
4
|
-
function CommandIcon(props) {
|
|
5
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
6
|
-
width: "15",
|
|
7
|
-
height: "15",
|
|
8
|
-
"aria-label": props.ariaLabel,
|
|
9
|
-
role: "img"
|
|
10
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
11
|
-
fill: "none",
|
|
12
|
-
stroke: "currentColor",
|
|
13
|
-
strokeLinecap: "round",
|
|
14
|
-
strokeLinejoin: "round",
|
|
15
|
-
strokeWidth: "1.2"
|
|
16
|
-
}, props.children));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function Footer(_ref) {
|
|
20
|
-
var _ref$translations = _ref.translations,
|
|
21
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations;
|
|
22
|
-
var _translations$selectT = translations.selectText,
|
|
23
|
-
selectText = _translations$selectT === void 0 ? 'to select' : _translations$selectT,
|
|
24
|
-
_translations$selectK = translations.selectKeyAriaLabel,
|
|
25
|
-
selectKeyAriaLabel = _translations$selectK === void 0 ? 'Enter key' : _translations$selectK,
|
|
26
|
-
_translations$navigat = translations.navigateText,
|
|
27
|
-
navigateText = _translations$navigat === void 0 ? 'to navigate' : _translations$navigat,
|
|
28
|
-
_translations$navigat2 = translations.navigateUpKeyAriaLabel,
|
|
29
|
-
navigateUpKeyAriaLabel = _translations$navigat2 === void 0 ? 'Arrow up' : _translations$navigat2,
|
|
30
|
-
_translations$navigat3 = translations.navigateDownKeyAriaLabel,
|
|
31
|
-
navigateDownKeyAriaLabel = _translations$navigat3 === void 0 ? 'Arrow down' : _translations$navigat3,
|
|
32
|
-
_translations$closeTe = translations.closeText,
|
|
33
|
-
closeText = _translations$closeTe === void 0 ? 'to close' : _translations$closeTe,
|
|
34
|
-
_translations$closeKe = translations.closeKeyAriaLabel,
|
|
35
|
-
closeKeyAriaLabel = _translations$closeKe === void 0 ? 'Escape key' : _translations$closeKe,
|
|
36
|
-
_translations$searchB = translations.searchByText,
|
|
37
|
-
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
|
|
38
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
className: "DocSearch-Logo"
|
|
40
|
-
}, /*#__PURE__*/React.createElement(AlgoliaLogo, {
|
|
41
|
-
translations: {
|
|
42
|
-
searchByText: searchByText
|
|
43
|
-
}
|
|
44
|
-
})), /*#__PURE__*/React.createElement("ul", {
|
|
45
|
-
className: "DocSearch-Commands"
|
|
46
|
-
}, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", {
|
|
47
|
-
className: "DocSearch-Commands-Key"
|
|
48
|
-
}, /*#__PURE__*/React.createElement(CommandIcon, {
|
|
49
|
-
ariaLabel: selectKeyAriaLabel
|
|
50
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
51
|
-
d: "M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"
|
|
52
|
-
}))), /*#__PURE__*/React.createElement("span", {
|
|
53
|
-
className: "DocSearch-Label"
|
|
54
|
-
}, selectText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", {
|
|
55
|
-
className: "DocSearch-Commands-Key"
|
|
56
|
-
}, /*#__PURE__*/React.createElement(CommandIcon, {
|
|
57
|
-
ariaLabel: navigateDownKeyAriaLabel
|
|
58
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
59
|
-
d: "M7.5 3.5v8M10.5 8.5l-3 3-3-3"
|
|
60
|
-
}))), /*#__PURE__*/React.createElement("kbd", {
|
|
61
|
-
className: "DocSearch-Commands-Key"
|
|
62
|
-
}, /*#__PURE__*/React.createElement(CommandIcon, {
|
|
63
|
-
ariaLabel: navigateUpKeyAriaLabel
|
|
64
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
65
|
-
d: "M7.5 11.5v-8M10.5 6.5l-3-3-3 3"
|
|
66
|
-
}))), /*#__PURE__*/React.createElement("span", {
|
|
67
|
-
className: "DocSearch-Label"
|
|
68
|
-
}, navigateText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", {
|
|
69
|
-
className: "DocSearch-Commands-Key"
|
|
70
|
-
}, /*#__PURE__*/React.createElement(CommandIcon, {
|
|
71
|
-
ariaLabel: closeKeyAriaLabel
|
|
72
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
73
|
-
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"
|
|
74
|
-
}))), /*#__PURE__*/React.createElement("span", {
|
|
75
|
-
className: "DocSearch-Label"
|
|
76
|
-
}, closeText))));
|
|
77
|
-
}
|
package/dist/esm/Hit.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
3
|
-
interface HitProps {
|
|
4
|
-
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare function Hit({ hit, children }: HitProps): JSX.Element;
|
|
8
|
-
export {};
|
package/dist/esm/Hit.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ScreenStateProps } from './ScreenState';
|
|
2
|
-
import type { InternalDocSearchHit } from './types';
|
|
3
|
-
export declare type NoResultsScreenTranslations = Partial<{
|
|
4
|
-
noResultsText: string;
|
|
5
|
-
suggestedQueryText: string;
|
|
6
|
-
reportMissingResultsText: string;
|
|
7
|
-
reportMissingResultsLinkText: string;
|
|
8
|
-
}>;
|
|
9
|
-
declare type NoResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'> & {
|
|
10
|
-
translations?: NoResultsScreenTranslations;
|
|
11
|
-
};
|
|
12
|
-
export declare function NoResultsScreen({ translations, ...props }: NoResultsScreenProps): JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var _excluded = ["translations"];
|
|
2
|
-
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
|
|
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."); }
|
|
6
|
-
|
|
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); }
|
|
8
|
-
|
|
9
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
-
|
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
-
|
|
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; }
|
|
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
|
-
|
|
19
|
-
import React from 'react';
|
|
20
|
-
import { NoResultsIcon } from './icons';
|
|
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$reportM = translations.reportMissingResultsText,
|
|
31
|
-
reportMissingResultsText = _translations$reportM === void 0 ? 'Believe this query should return results?' : _translations$reportM,
|
|
32
|
-
_translations$reportM2 = translations.reportMissingResultsLinkText,
|
|
33
|
-
reportMissingResultsLinkText = _translations$reportM2 === void 0 ? 'Let us know.' : _translations$reportM2;
|
|
34
|
-
var searchSuggestions = props.state.context.searchSuggestions;
|
|
35
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
className: "DocSearch-NoResults"
|
|
37
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
38
|
-
className: "DocSearch-Screen-Icon"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(NoResultsIcon, null)), /*#__PURE__*/React.createElement("p", {
|
|
40
|
-
className: "DocSearch-Title"
|
|
41
|
-
}, noResultsText, " \"", /*#__PURE__*/React.createElement("strong", null, props.state.query), "\""), searchSuggestions && searchSuggestions.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
42
|
-
className: "DocSearch-NoResults-Prefill-List"
|
|
43
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
44
|
-
className: "DocSearch-Help"
|
|
45
|
-
}, suggestedQueryText, ":"), /*#__PURE__*/React.createElement("ul", null, searchSuggestions.slice(0, 3).reduce(function (acc, search) {
|
|
46
|
-
return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement("li", {
|
|
47
|
-
key: search
|
|
48
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
49
|
-
className: "DocSearch-Prefill",
|
|
50
|
-
key: search,
|
|
51
|
-
type: "button",
|
|
52
|
-
onClick: function onClick() {
|
|
53
|
-
props.setQuery(search.toLowerCase() + ' ');
|
|
54
|
-
props.refresh();
|
|
55
|
-
props.inputRef.current.focus();
|
|
56
|
-
}
|
|
57
|
-
}, search))]);
|
|
58
|
-
}, []))), props.getMissingResultsUrl && /*#__PURE__*/React.createElement("p", {
|
|
59
|
-
className: "DocSearch-Help"
|
|
60
|
-
}, "".concat(reportMissingResultsText, " "), /*#__PURE__*/React.createElement("a", {
|
|
61
|
-
href: props.getMissingResultsUrl({
|
|
62
|
-
query: props.state.query
|
|
63
|
-
}),
|
|
64
|
-
target: "_blank",
|
|
65
|
-
rel: "noopener noreferrer"
|
|
66
|
-
}, reportMissingResultsLinkText)));
|
|
67
|
-
}
|
package/dist/esm/Results.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { DocSearchProps } from './DocSearch';
|
|
4
|
-
import type { StoredDocSearchHit } from './types';
|
|
5
|
-
interface ResultsProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
|
|
6
|
-
title: string;
|
|
7
|
-
collection: AutocompleteState<TItem>['collections'][0];
|
|
8
|
-
renderIcon: (props: {
|
|
9
|
-
item: TItem;
|
|
10
|
-
index: number;
|
|
11
|
-
}) => React.ReactNode;
|
|
12
|
-
renderAction: (props: {
|
|
13
|
-
item: TItem;
|
|
14
|
-
runDeleteTransition: (cb: () => void) => void;
|
|
15
|
-
runFavoriteTransition: (cb: () => void) => void;
|
|
16
|
-
}) => React.ReactNode;
|
|
17
|
-
onItemClick: (item: TItem, event: KeyboardEvent | MouseEvent) => void;
|
|
18
|
-
hitComponent: DocSearchProps['hitComponent'];
|
|
19
|
-
}
|
|
20
|
-
export declare function Results<TItem extends StoredDocSearchHit>(props: ResultsProps<TItem>): JSX.Element | null;
|
|
21
|
-
export {};
|