@docsearch/react 3.6.3 → 3.8.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.
@@ -1,6 +1,5 @@
1
- import { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
2
- import { SearchClient } from 'algoliasearch';
3
- import { SearchQuery, LiteClient } from 'algoliasearch/lite';
1
+ import { BaseItem, AutocompleteState, AutocompleteContext, AutocompleteInsightsApi, AutocompleteOptions } from '@algolia/autocomplete-core';
2
+ import { LiteClient, SearchForHits } from 'algoliasearch/lite';
4
3
  import React from 'react';
5
4
 
6
5
  type ContentType = 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
@@ -78,6 +77,15 @@ declare type DocSearchHit = {
78
77
  __autocomplete_id?: number;
79
78
  };
80
79
 
80
+ interface DocSearchContext extends AutocompleteContext {
81
+ algoliaInsightsPlugin?: {
82
+ insights: AutocompleteInsightsApi;
83
+ };
84
+ }
85
+ interface DocSearchState<TItem extends BaseItem> extends AutocompleteState<TItem> {
86
+ context: DocSearchContext;
87
+ }
88
+
81
89
  type InternalDocSearchHit = DocSearchHit & {
82
90
  __docsearch_parent: InternalDocSearchHit | null;
83
91
  };
@@ -88,12 +96,17 @@ type DocSearchTranslations = Partial<{
88
96
  button: ButtonTranslations;
89
97
  modal: ModalTranslations;
90
98
  }>;
99
+ type DocSearchTransformClient = {
100
+ search: LiteClient['search'];
101
+ addAlgoliaAgent: LiteClient['addAlgoliaAgent'];
102
+ transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;
103
+ };
91
104
  interface DocSearchProps {
92
105
  appId: string;
93
106
  apiKey: string;
94
107
  indexName: string;
95
108
  placeholder?: string;
96
- searchParameters?: SearchQuery;
109
+ searchParameters?: SearchForHits;
97
110
  maxResultsPerGroup?: number;
98
111
  transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
99
112
  hitComponent?: (props: {
@@ -103,7 +116,7 @@ interface DocSearchProps {
103
116
  resultsFooterComponent?: (props: {
104
117
  state: AutocompleteState<InternalDocSearchHit>;
105
118
  }) => JSX.Element | null;
106
- transformSearchClient?: <T extends LiteClient | SearchClient>(searchClient: T) => T;
119
+ transformSearchClient?: (searchClient: DocSearchTransformClient) => DocSearchTransformClient;
107
120
  disableUserPersonalization?: boolean;
108
121
  initialQuery?: string;
109
122
  navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
@@ -113,7 +126,7 @@ interface DocSearchProps {
113
126
  }) => string;
114
127
  insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];
115
128
  }
116
- declare function DocSearch(props: DocSearchProps): React.JSX.Element;
129
+ declare function DocSearch(props: DocSearchProps): JSX.Element;
117
130
 
118
131
  type ButtonTranslations = Partial<{
119
132
  buttonText: string;
@@ -179,7 +192,7 @@ type DocSearchModalProps = DocSearchProps & {
179
192
  onClose?: () => void;
180
193
  translations?: ModalTranslations;
181
194
  };
182
- declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, maxResultsPerGroup, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, }: DocSearchModalProps): React.JSX.Element;
195
+ declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, maxResultsPerGroup, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, }: DocSearchModalProps): JSX.Element;
183
196
 
184
197
  interface UseDocSearchKeyboardEventsProps {
185
198
  isOpen: boolean;
@@ -190,6 +203,6 @@ interface UseDocSearchKeyboardEventsProps {
190
203
  }
191
204
  declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, searchButtonRef, }: UseDocSearchKeyboardEventsProps): void;
192
205
 
193
- declare const version = "3.6.3";
206
+ declare const version = "3.8.0";
194
207
 
195
- export { type ButtonTranslations, DocSearch, DocSearchButton, type DocSearchButtonProps, DocSearchModal, type DocSearchModalProps, type DocSearchProps, type DocSearchTranslations, type ModalTranslations, type UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
208
+ export { type ButtonTranslations, DocSearch, DocSearchButton, type DocSearchButtonProps, type DocSearchHit, DocSearchModal, type DocSearchModalProps, type DocSearchProps, type DocSearchState, type DocSearchTransformClient, type DocSearchTranslations, type InternalDocSearchHit, type ModalTranslations, type StoredDocSearchHit, type UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };