@docsearch/react 4.0.0-beta.7 → 4.0.0
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 +3 -3
- package/dist/esm/index.d.ts +58 -8
- package/dist/esm/index.js +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -5,15 +5,15 @@ React package for [DocSearch](http://docsearch.algolia.com/), the best search ex
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
yarn add @docsearch/react@
|
|
8
|
+
yarn add @docsearch/react@4
|
|
9
9
|
# or
|
|
10
|
-
npm install @docsearch/react@
|
|
10
|
+
npm install @docsearch/react@4
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
If you don’t want to use a package manager, you can use a standalone endpoint:
|
|
14
14
|
|
|
15
15
|
```html
|
|
16
|
-
<script src="https://cdn.jsdelivr.net/npm/@docsearch/react@
|
|
16
|
+
<script src="https://cdn.jsdelivr.net/npm/@docsearch/react@4"></script>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Get started
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseItem, AutocompleteState, AutocompleteContext, AutocompleteInsightsApi, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
2
2
|
import { LiteClient, SearchParamsObject } from 'algoliasearch/lite';
|
|
3
3
|
import React, { JSX } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { UIMessage } from '@ai-sdk/react';
|
|
5
|
+
import { UIDataTypes } from 'ai';
|
|
5
6
|
|
|
6
7
|
type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
|
|
7
8
|
interface DocSearchHitAttributeHighlightResult {
|
|
@@ -94,8 +95,36 @@ type InternalDocSearchHit = DocSearchHit & {
|
|
|
94
95
|
__docsearch_parent: InternalDocSearchHit | null;
|
|
95
96
|
};
|
|
96
97
|
|
|
98
|
+
interface KeyboardShortcuts {
|
|
99
|
+
/**
|
|
100
|
+
* Enable/disable the Ctrl/Cmd+K shortcut to toggle the search modal.
|
|
101
|
+
*
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
104
|
+
'Ctrl/Cmd+K'?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Enable/disable the / shortcut to open the search modal.
|
|
107
|
+
*
|
|
108
|
+
* @default true
|
|
109
|
+
*/
|
|
110
|
+
'/'?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface SearchIndexTool {
|
|
114
|
+
input: {
|
|
115
|
+
query: string;
|
|
116
|
+
};
|
|
117
|
+
output: {
|
|
118
|
+
query?: string;
|
|
119
|
+
hits?: any[];
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
type AIMessage = UIMessage<unknown, UIDataTypes, {
|
|
123
|
+
searchIndex: SearchIndexTool;
|
|
124
|
+
}>;
|
|
125
|
+
|
|
97
126
|
type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
|
|
98
|
-
type StoredAskAiMessage =
|
|
127
|
+
type StoredAskAiMessage = AIMessage & {
|
|
99
128
|
/** Optional user feedback on this assistant message. */
|
|
100
129
|
feedback?: 'dislike' | 'like';
|
|
101
130
|
};
|
|
@@ -139,6 +168,10 @@ type DocSearchAskAi = {
|
|
|
139
168
|
facetFilters?: SearchParamsObject['facetFilters'];
|
|
140
169
|
};
|
|
141
170
|
};
|
|
171
|
+
interface DocSearchIndex {
|
|
172
|
+
name: string;
|
|
173
|
+
searchParameters?: SearchParamsObject;
|
|
174
|
+
}
|
|
142
175
|
interface DocSearchProps {
|
|
143
176
|
/**
|
|
144
177
|
* Algolia application id used by the search client.
|
|
@@ -150,8 +183,16 @@ interface DocSearchProps {
|
|
|
150
183
|
apiKey: string;
|
|
151
184
|
/**
|
|
152
185
|
* Name of the algolia index to query.
|
|
186
|
+
*
|
|
187
|
+
* @deprecated `indexName` will be removed in a future version. Please use `indices` property going forward.
|
|
188
|
+
*/
|
|
189
|
+
indexName?: string;
|
|
190
|
+
/**
|
|
191
|
+
* List of indices and _optional_ searchParameters to be used for search.
|
|
192
|
+
*
|
|
193
|
+
* @see {@link https://docsearch.algolia.com/docs/api#indices}
|
|
153
194
|
*/
|
|
154
|
-
|
|
195
|
+
indices?: Array<DocSearchIndex | string>;
|
|
155
196
|
/**
|
|
156
197
|
* Configuration or assistant id to enable ask ai mode. Pass a string assistant id or a full config object.
|
|
157
198
|
*/
|
|
@@ -166,6 +207,8 @@ interface DocSearchProps {
|
|
|
166
207
|
placeholder?: string;
|
|
167
208
|
/**
|
|
168
209
|
* Additional algolia search parameters to merge into each query.
|
|
210
|
+
*
|
|
211
|
+
* @deprecated `searchParameters` will be removed in a future version. Please use `indices` property going forward.
|
|
169
212
|
*/
|
|
170
213
|
searchParameters?: SearchParamsObject;
|
|
171
214
|
/**
|
|
@@ -235,8 +278,12 @@ interface DocSearchProps {
|
|
|
235
278
|
* @default 4
|
|
236
279
|
*/
|
|
237
280
|
recentSearchesWithFavoritesLimit?: number;
|
|
281
|
+
/**
|
|
282
|
+
* Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
|
|
283
|
+
*/
|
|
284
|
+
keyboardShortcuts?: KeyboardShortcuts;
|
|
238
285
|
}
|
|
239
|
-
declare function DocSearch({ ...props }: DocSearchProps): JSX.Element;
|
|
286
|
+
declare function DocSearch({ indexName, searchParameters, indices, ...props }: DocSearchProps): JSX.Element;
|
|
240
287
|
|
|
241
288
|
type ButtonTranslations = Partial<{
|
|
242
289
|
buttonText: string;
|
|
@@ -245,6 +292,7 @@ type ButtonTranslations = Partial<{
|
|
|
245
292
|
type DocSearchButtonProps = React.ComponentProps<'button'> & {
|
|
246
293
|
theme?: DocSearchTheme;
|
|
247
294
|
translations?: ButtonTranslations;
|
|
295
|
+
keyboardShortcuts?: KeyboardShortcuts;
|
|
248
296
|
};
|
|
249
297
|
declare const DocSearchButton: React.ForwardRefExoticComponent<Omit<DocSearchButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
250
298
|
|
|
@@ -353,8 +401,9 @@ type DocSearchModalProps = DocSearchProps & {
|
|
|
353
401
|
isAskAiActive?: boolean;
|
|
354
402
|
canHandleAskAi?: boolean;
|
|
355
403
|
translations?: ModalTranslations;
|
|
404
|
+
indexes: DocSearchIndex[];
|
|
356
405
|
};
|
|
357
|
-
declare function DocSearchModal({ appId, apiKey,
|
|
406
|
+
declare function DocSearchModal({ appId, apiKey, placeholder, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, isAskAiActive, canHandleAskAi, recentSearchesLimit, recentSearchesWithFavoritesLimit, indexes, }: DocSearchModalProps): JSX.Element;
|
|
358
407
|
|
|
359
408
|
interface UseDocSearchKeyboardEventsProps {
|
|
360
409
|
isOpen: boolean;
|
|
@@ -364,10 +413,11 @@ interface UseDocSearchKeyboardEventsProps {
|
|
|
364
413
|
searchButtonRef: React.RefObject<HTMLButtonElement | null>;
|
|
365
414
|
isAskAiActive: boolean;
|
|
366
415
|
onAskAiToggle: (toggle: boolean) => void;
|
|
416
|
+
keyboardShortcuts?: KeyboardShortcuts;
|
|
367
417
|
}
|
|
368
|
-
declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, isAskAiActive, onAskAiToggle, searchButtonRef, }: UseDocSearchKeyboardEventsProps): void;
|
|
418
|
+
declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, isAskAiActive, onAskAiToggle, searchButtonRef, keyboardShortcuts, }: UseDocSearchKeyboardEventsProps): void;
|
|
369
419
|
|
|
370
|
-
declare const version = "4.0.0
|
|
420
|
+
declare const version = "4.0.0";
|
|
371
421
|
|
|
372
422
|
export { DocSearch, DocSearchButton, DocSearchModal, useDocSearchKeyboardEvents, version };
|
|
373
|
-
export type { ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, ModalTranslations, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, UseDocSearchKeyboardEventsProps };
|
|
423
|
+
export type { ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchIndex, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, ModalTranslations, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, UseDocSearchKeyboardEventsProps };
|