@docsearch/react 4.4.0 → 4.5.0-beta.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,4 +1,5 @@
1
- import { SidepanelShortcuts, InitialAskAiMessage, DocSearchTheme } from '@docsearch/core';
1
+ import { SidepanelShortcuts, InitialAskAiMessage, DocSearchCallbacks, DocSearchTheme, DocSearchRef } from '@docsearch/core';
2
+ export { DocSearchCallbacks, DocSearchRef } from '@docsearch/core';
2
3
  import React, { JSX } from 'react';
3
4
 
4
5
  type AskAiSearchParameters = {
@@ -122,6 +123,19 @@ type HeaderTranslations = Partial<{
122
123
  viewConversationHistoryText: string;
123
124
  }>;
124
125
 
126
+ /**
127
+ * Imperative handle exposed by the Sidepanel component for programmatic control.
128
+ */
129
+ interface SidepanelRef {
130
+ /** Opens the sidepanel. */
131
+ open: () => void;
132
+ /** Closes the sidepanel. */
133
+ close: () => void;
134
+ /** Returns true once the component is mounted and ready. */
135
+ readonly isReady: boolean;
136
+ /** Returns true if the sidepanel is currently open. */
137
+ readonly isOpen: boolean;
138
+ }
125
139
  type SidepanelTranslations = Partial<{
126
140
  /**
127
141
  * Translation texts for the Sidepanel header.
@@ -200,14 +214,14 @@ type SidepanelProps = {
200
214
  * @default `{ 'Ctrl/Cmd+I': true }`
201
215
  */
202
216
  keyboardShortcuts?: SidepanelShortcuts;
217
+ useStagingEnv?: boolean;
203
218
  };
204
- type Props$1 = Omit<DocSearchSidepanelProps, 'button' | 'panel'> & SidepanelProps & {
219
+ declare const Sidepanel: React.ForwardRefExoticComponent<Omit<DocSearchSidepanelProps, "button" | "panel"> & SidepanelProps & {
205
220
  isOpen?: boolean;
206
221
  onOpen: () => void;
207
222
  onClose: () => void;
208
223
  initialMessage?: InitialAskAiMessage;
209
- };
210
- declare const Sidepanel: ({ isOpen, onOpen, onClose, assistantId, apiKey, appId, indexName, variant, searchParameters, pushSelector, width, expandedWidth, suggestedQuestions: suggestedQuestionsEnabled, translations, keyboardShortcuts, side, initialMessage, }: Props$1) => JSX.Element;
224
+ } & React.RefAttributes<SidepanelRef>>;
211
225
 
212
226
  type SidepanelButtonTranslations = Partial<{
213
227
  /**
@@ -248,7 +262,7 @@ type SidepanelButtonProps = {
248
262
  type Props = React.ComponentProps<'button'> & SidepanelButtonProps;
249
263
  declare const SidepanelButton: ({ variant, keyboardShortcuts, translations, ...props }: Props) => JSX.Element;
250
264
 
251
- type DocSearchSidepanelProps = {
265
+ type DocSearchSidepanelProps = DocSearchCallbacks & {
252
266
  /**
253
267
  * The assistant ID to use for the ask AI feature.
254
268
  */
@@ -290,7 +304,48 @@ type DocSearchSidepanelProps = {
290
304
  */
291
305
  panel?: Omit<SidepanelProps, 'keyboardShortcuts'>;
292
306
  };
293
- declare function DocSearchSidepanel({ keyboardShortcuts, theme, ...props }: DocSearchSidepanelProps): JSX.Element;
307
+ declare const DocSearchSidepanel: React.ForwardRefExoticComponent<DocSearchCallbacks & {
308
+ /**
309
+ * The assistant ID to use for the ask AI feature.
310
+ */
311
+ assistantId: string;
312
+ /**
313
+ * Public api key with search permissions for the index.
314
+ */
315
+ apiKey: string;
316
+ /**
317
+ * Algolia application id used by the search client.
318
+ */
319
+ appId: string;
320
+ /**
321
+ * The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
322
+ */
323
+ indexName: string;
324
+ /**
325
+ * The search parameters to use for the ask AI feature.
326
+ */
327
+ searchParameters?: AskAiSearchParameters;
328
+ /**
329
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
330
+ *
331
+ * @default `{ 'Ctrl/Cmd+I': true }`
332
+ */
333
+ keyboardShortcuts?: SidepanelShortcuts;
334
+ /**
335
+ * Theme overrides applied to the Sidepanel button and panel.
336
+ *
337
+ * @default 'light'
338
+ */
339
+ theme?: DocSearchTheme;
340
+ /**
341
+ * Props specific to the Sidepanel button.
342
+ */
343
+ button?: Omit<SidepanelButtonProps, "keyboardShortcuts">;
344
+ /**
345
+ * Props specific to the Sidepanel panel.
346
+ */
347
+ panel?: Omit<SidepanelProps, "keyboardShortcuts">;
348
+ } & React.RefAttributes<DocSearchRef>>;
294
349
 
295
350
  export { DocSearchSidepanel, Sidepanel, SidepanelButton };
296
- export type { ButtonVariant, DocSearchSidepanelProps, SidepanelButtonProps, SidepanelButtonTranslations, SidepanelProps, SidepanelTranslations };
351
+ export type { ButtonVariant, DocSearchSidepanelProps, SidepanelButtonProps, SidepanelButtonTranslations, SidepanelProps, SidepanelRef, SidepanelTranslations };