@docsearch/react 4.6.2 → 5.0.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.
Files changed (79) hide show
  1. package/README.md +0 -2
  2. package/dist/esm/AskAiScreenState-D0IZsCMJ.d.ts +106 -0
  3. package/dist/esm/DocSearch-Dq5Utfyb.d.ts +295 -0
  4. package/dist/esm/DocSearchAskAiModal-BwbMrrHv.d.ts +48 -0
  5. package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js +954 -0
  6. package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js.map +1 -0
  7. package/dist/esm/DocSearchButton-CRlNPf5k.d.ts +18 -0
  8. package/dist/esm/DocSearchButton-CaxxOzQU.js +71 -0
  9. package/dist/esm/DocSearchButton-CaxxOzQU.js.map +1 -0
  10. package/dist/esm/DocSearchModal-CpvDjo1O.js +250 -0
  11. package/dist/esm/DocSearchModal-CpvDjo1O.js.map +1 -0
  12. package/dist/esm/DocSearchTheme-DvL4mf0D.d.ts +5 -0
  13. package/dist/esm/askaiModal.d.ts +2 -0
  14. package/dist/esm/askaiModal.js +3 -0
  15. package/dist/esm/button.d.ts +2 -0
  16. package/dist/esm/button.js +3 -0
  17. package/dist/esm/docsearchAi.d.ts +220 -0
  18. package/dist/esm/docsearchAi.js +34 -0
  19. package/dist/esm/docsearchAi.js.map +1 -0
  20. package/dist/esm/index-Dl8FMlR5.d.ts +223 -0
  21. package/dist/esm/index.d.ts +9 -567
  22. package/dist/esm/index.js +35 -3
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/keyboard-BkSdCzTU.js +9 -0
  25. package/dist/esm/keyboard-BkSdCzTU.js.map +1 -0
  26. package/dist/esm/keyboardShortcuts-C-lx6Xt7.js +25 -0
  27. package/dist/esm/keyboardShortcuts-C-lx6Xt7.js.map +1 -0
  28. package/dist/esm/modal.d.ts +2 -0
  29. package/dist/esm/modal.js +3 -0
  30. package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js +1240 -0
  31. package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js.map +1 -0
  32. package/dist/esm/objectSpread2-BNmiQYyW.js +67 -0
  33. package/dist/esm/objectWithoutProperties-phqYxDS0.js +53 -0
  34. package/dist/esm/objectWithoutProperties-phqYxDS0.js.map +1 -0
  35. package/dist/esm/sidepanel.d.ts +395 -0
  36. package/dist/esm/sidepanel.js +773 -0
  37. package/dist/esm/sidepanel.js.map +1 -0
  38. package/dist/esm/useDocSearchKeyboardEvents-68G8dw6c.d.ts +43 -0
  39. package/dist/esm/useDocSearchKeyboardEvents.d.ts +2 -41
  40. package/dist/esm/useDocSearchKeyboardEvents.js +43 -1
  41. package/dist/esm/useDocSearchKeyboardEvents.js.map +1 -0
  42. package/dist/esm/useSearchClient-mIHVB6ga.js +433 -0
  43. package/dist/esm/useSearchClient-mIHVB6ga.js.map +1 -0
  44. package/dist/esm/useSuggestedQuestions-D2TGVPsI.js +1112 -0
  45. package/dist/esm/useSuggestedQuestions-D2TGVPsI.js.map +1 -0
  46. package/dist/esm/useTheme.d.ts +7 -6
  47. package/dist/esm/useTheme.js +21 -1
  48. package/dist/esm/useTheme.js.map +1 -0
  49. package/dist/esm/version.d.ts +4 -2
  50. package/dist/esm/version.js +6 -1
  51. package/dist/esm/version.js.map +1 -0
  52. package/dist/umd/index.js +175 -5
  53. package/dist/umd/index.js.map +1 -1
  54. package/package.json +31 -34
  55. package/style/askai.js +1 -0
  56. package/button.js +0 -1
  57. package/dist/esm/DocSearchButton.d.ts +0 -18
  58. package/dist/esm/DocSearchButton.js +0 -1
  59. package/dist/esm/DocSearchModal.d.ts +0 -448
  60. package/dist/esm/DocSearchModal.js +0 -3
  61. package/dist/esm/Sidepanel.d.ts +0 -349
  62. package/dist/esm/Sidepanel.js +0 -3
  63. package/dist/umd/DocSearchModal.js +0 -5
  64. package/dist/umd/DocSearchModal.js.map +0 -1
  65. package/dist/umd/DocsearchButton.js +0 -3
  66. package/dist/umd/DocsearchButton.js.map +0 -1
  67. package/dist/umd/Sidepanel.js +0 -5
  68. package/dist/umd/Sidepanel.js.map +0 -1
  69. package/dist/umd/useDocSearchKeyboardEvents.js +0 -3
  70. package/dist/umd/useDocSearchKeyboardEvents.js.map +0 -1
  71. package/dist/umd/useTheme.js +0 -3
  72. package/dist/umd/useTheme.js.map +0 -1
  73. package/dist/umd/version.js +0 -3
  74. package/dist/umd/version.js.map +0 -1
  75. package/modal.js +0 -1
  76. package/sidepanel.js +0 -1
  77. package/useDocSearchKeyboardEvents.js +0 -1
  78. package/useTheme.js +0 -1
  79. package/version.js +0 -1
@@ -0,0 +1,395 @@
1
+ import { o as ToolCalls } from "./index-Dl8FMlR5.js";
2
+ import "./DocSearch-Dq5Utfyb.js";
3
+ import { AgentStudioIndices, AgentStudioSearchParameters, Memory } from "./docsearchAi.js";
4
+ import { r as ToolCallTranslations } from "./AskAiScreenState-D0IZsCMJ.js";
5
+ import { DocSearchCallbacks, DocSearchCallbacks as DocSearchCallbacks$1, DocSearchRef, DocSearchRef as DocSearchRef$1, DocSearchTheme, InitialAskAiMessage, SidepanelShortcuts } from "@docsearch/core";
6
+ import React, { JSX } from "react";
7
+ import "@ai-sdk/react";
8
+ //#region src/AlgoliaLogo.d.ts
9
+ type AlgoliaLogoTranslations = Partial<{
10
+ poweredByText: string;
11
+ }>;
12
+ //#endregion
13
+ //#region src/Sidepanel/ConversationScreen.d.ts
14
+ type ConversationScreenTranslations = Partial<ToolCallTranslations & {
15
+ /** Text shown as an LLM disclaimer. */
16
+ conversationDisclaimer: string;
17
+ /** Text shown while assistant is reasoning. */
18
+ reasoningText: string;
19
+ /** Text show while assistant is thinking. */
20
+ thinkingText: string;
21
+ /** Text shown describing related sources. */
22
+ relatedSourcesText: string;
23
+ /** Message that's shown when user has stopped the streaming of a message. */
24
+ stoppedStreamingText: string;
25
+ /** Text shown for copy button on code snippets. */
26
+ copyButtonText: string;
27
+ /** Message shown after clicking copy. */
28
+ copyButtonCopiedText: string;
29
+ /** Title for thumbs up feedback icon. */
30
+ likeButtonTitle: string;
31
+ /** Title for thumbs down feedback icon. */
32
+ dislikeButtonTitle: string;
33
+ /** Message displayed after feedback action. */
34
+ thanksForFeedbackText: string;
35
+ /** Title shown at the top of the negative feedback note panel. */
36
+ feedbackPanelTitle: string;
37
+ /** Placeholder for the negative feedback details textarea. */
38
+ feedbackDetailsPlaceholder: string;
39
+ /** Disclaimer shown inside the negative feedback note panel. */
40
+ feedbackDisclaimerText: string;
41
+ /** Submit button text for the negative feedback note panel. */
42
+ feedbackSubmitButtonText: string;
43
+ /** Accessible title for the negative feedback note panel close button. */
44
+ feedbackCloseButtonTitle: string;
45
+ /** Reason chip labels for the negative feedback note panel. */
46
+ feedbackTagIncorrect: string;
47
+ feedbackTagNotWhatIAsked: string;
48
+ feedbackTagSlowOrBuggy: string;
49
+ feedbackTagStyleOrTone: string;
50
+ feedbackTagSafetyOrLegal: string;
51
+ feedbackTagOther: string;
52
+ /** Error title shown if there is an error while chatting. */
53
+ errorTitleText: any;
54
+ suggestedPromptsTitleText: string;
55
+ }>;
56
+ //#endregion
57
+ //#region src/Sidepanel/NewConversationScreen.d.ts
58
+ type NewConversationScreenTranslations = Partial<{
59
+ /** Title to be shown on the new conversation/starting screen. */
60
+ titleText: string;
61
+ /** Introduction text displayed on the new conversation/starting screen. */
62
+ introductionText: string;
63
+ }>;
64
+ //#endregion
65
+ //#region src/Sidepanel/PromptForm.d.ts
66
+ type PromptFormTranslations = Partial<{
67
+ /** Initial placeholder for the prompt input. */
68
+ promptPlaceholderText: string;
69
+ /** Placeholder text for wile a conversation is streaming. */
70
+ promptAnsweringText: string;
71
+ /** Placeholder text for after a question has already been asked. */
72
+ promptAskAnotherQuestionText: string;
73
+ /** Disclaimer text displayed beneath the prompt form. */
74
+ promptDisclaimerText: string;
75
+ promptLabelText: string;
76
+ promptAriaLabelText: string;
77
+ }>;
78
+ //#endregion
79
+ //#region src/Sidepanel/types.d.ts
80
+ type PanelVariant = 'floating' | 'inline';
81
+ type PanelSide = 'left' | 'right';
82
+ //#endregion
83
+ //#region src/Sidepanel/SidepanelHeader.d.ts
84
+ type HeaderTranslations = Partial<{
85
+ /** The main title text shown on the header. */
86
+ title: string;
87
+ /** The title text shown on the conversation history screen. */
88
+ conversationHistoryTitle: string;
89
+ /** The text shown on the start a conversation button. */
90
+ newConversationText: string;
91
+ /** The text shown on the view conversation history button. */
92
+ viewConversationHistoryText: string;
93
+ }>;
94
+ //#endregion
95
+ //#region src/Sidepanel/Sidepanel.d.ts
96
+ /**
97
+ * Imperative handle exposed by the Sidepanel component for programmatic
98
+ * control.
99
+ */
100
+ interface SidepanelRef {
101
+ /** Opens the sidepanel. */
102
+ open: () => void;
103
+ /** Closes the sidepanel. */
104
+ close: () => void;
105
+ /** Returns true once the component is mounted and ready. */
106
+ readonly isReady: boolean;
107
+ /** Returns true if the sidepanel is currently open. */
108
+ readonly isOpen: boolean;
109
+ }
110
+ type SidepanelTranslations = Partial<{
111
+ /** Translation texts for the Sidepanel header. */
112
+ header: HeaderTranslations;
113
+ /** Translation texts for the prompt form. */
114
+ promptForm: PromptFormTranslations;
115
+ /** Translation texts for the conversation screen. */
116
+ conversationScreen: ConversationScreenTranslations;
117
+ /** Translation texts for the new conversation/starting screen. */
118
+ newConversationScreen: NewConversationScreenTranslations;
119
+ /** Translation text for the Algolia logo. */
120
+ logo: AlgoliaLogoTranslations;
121
+ }>;
122
+ type SidepanelProps = Pick<DocSearchSidepanelProps, 'indices' | 'memory' | 'tools'> & {
123
+ /**
124
+ * Variant of the Sidepanel positioning.
125
+ *
126
+ * - `inline` pushes page content when opened
127
+ * - `floating` is positioned above all other content on page.
128
+ *
129
+ * @default 'floating'
130
+ */
131
+ variant?: PanelVariant;
132
+ /**
133
+ * Side of the page which the panel will originate from.
134
+ *
135
+ * @default 'right'
136
+ */
137
+ side?: PanelSide;
138
+ /**
139
+ * The selector of the element to push when Sidepanel opens with `inline`
140
+ * variant.
141
+ *
142
+ * @default `'#root, main, .app, body'`
143
+ */
144
+ pushSelector?: string;
145
+ /**
146
+ * Width of the Sidepanel (px or any CSS width).
147
+ *
148
+ * @default `360px`
149
+ */
150
+ width?: number | string;
151
+ /**
152
+ * Width when expanded (px or any CSS width).
153
+ *
154
+ * @default `580px`
155
+ */
156
+ expandedWidth?: number | string;
157
+ /**
158
+ * The container element where the panel should be portaled to.
159
+ *
160
+ * @default `document.body`
161
+ */
162
+ portalContainer?: DocumentFragment | Element | null;
163
+ /**
164
+ * Enables displaying suggested questions on new conversation screen.
165
+ *
166
+ * @default false
167
+ */
168
+ suggestedQuestions?: boolean;
169
+ /** Translations specific to the Sidepanel panel. */
170
+ translations?: SidepanelTranslations;
171
+ /**
172
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific
173
+ * shortcuts.
174
+ *
175
+ * @default `{ 'Ctrl/Cmd+I': true }`
176
+ */
177
+ keyboardShortcuts?: SidepanelShortcuts;
178
+ };
179
+ declare const Sidepanel: React.ForwardRefExoticComponent<Omit<DocSearchSidepanelProps, "indices" | "button" | "panel" | "tools" | "memory"> & Pick<DocSearchSidepanelProps, "indices" | "tools" | "memory"> & {
180
+ /**
181
+ * Variant of the Sidepanel positioning.
182
+ *
183
+ * - `inline` pushes page content when opened
184
+ * - `floating` is positioned above all other content on page.
185
+ *
186
+ * @default 'floating'
187
+ */
188
+ variant?: PanelVariant;
189
+ /**
190
+ * Side of the page which the panel will originate from.
191
+ *
192
+ * @default 'right'
193
+ */
194
+ side?: PanelSide;
195
+ /**
196
+ * The selector of the element to push when Sidepanel opens with `inline`
197
+ * variant.
198
+ *
199
+ * @default `'#root, main, .app, body'`
200
+ */
201
+ pushSelector?: string;
202
+ /**
203
+ * Width of the Sidepanel (px or any CSS width).
204
+ *
205
+ * @default `360px`
206
+ */
207
+ width?: number | string;
208
+ /**
209
+ * Width when expanded (px or any CSS width).
210
+ *
211
+ * @default `580px`
212
+ */
213
+ expandedWidth?: number | string;
214
+ /**
215
+ * The container element where the panel should be portaled to.
216
+ *
217
+ * @default `document.body`
218
+ */
219
+ portalContainer?: DocumentFragment | Element | null;
220
+ /**
221
+ * Enables displaying suggested questions on new conversation screen.
222
+ *
223
+ * @default false
224
+ */
225
+ suggestedQuestions?: boolean;
226
+ /** Translations specific to the Sidepanel panel. */
227
+ translations?: SidepanelTranslations;
228
+ /**
229
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific
230
+ * shortcuts.
231
+ *
232
+ * @default `{ 'Ctrl/Cmd+I': true }`
233
+ */
234
+ keyboardShortcuts?: SidepanelShortcuts;
235
+ } & SidepanelSearchParameters & {
236
+ isOpen?: boolean;
237
+ onOpen: () => void;
238
+ onClose: () => void;
239
+ initialMessage?: InitialAskAiMessage;
240
+ } & React.RefAttributes<SidepanelRef>>;
241
+ //#endregion
242
+ //#region src/Sidepanel/SidepanelButton.d.ts
243
+ type SidepanelButtonTranslations = Partial<{
244
+ /**
245
+ * Text to be displayed when button has variant: `inline`.
246
+ *
247
+ * @default 'Ask AI'
248
+ */
249
+ buttonText: string;
250
+ /**
251
+ * Aria label text for the button.
252
+ *
253
+ * @default 'Ask AI'
254
+ */
255
+ buttonAriaLabel: string;
256
+ }>;
257
+ type ButtonVariant = 'floating' | 'inline';
258
+ type SidepanelButtonProps = {
259
+ /**
260
+ * Variant of the button positioning and styling.
261
+ *
262
+ * - `inline` displays the button inline where rendered, with extra text
263
+ * - `floating` displays the button floating in bottom right of screen with just
264
+ * icon.
265
+ *
266
+ * @default 'floating'
267
+ */
268
+ variant?: ButtonVariant;
269
+ /** Translations specific to the Sidepanel button. */
270
+ translations?: SidepanelButtonTranslations;
271
+ /**
272
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific
273
+ * shortcuts.
274
+ *
275
+ * @default `{ 'Ctrl/Cmd+I': true }`
276
+ */
277
+ keyboardShortcuts?: SidepanelShortcuts;
278
+ };
279
+ type Props = React.ComponentProps<'button'> & SidepanelButtonProps;
280
+ declare const SidepanelButton: ({ variant, keyboardShortcuts, translations, ...props }: Props) => JSX.Element;
281
+ //#endregion
282
+ //#region src/Sidepanel.d.ts
283
+ type SidepanelSearchParameters = {
284
+ /**
285
+ * The search parameters to use for the ask AI feature. Keyed by the index
286
+ * name.
287
+ *
288
+ * @example
289
+ * {
290
+ * "INDEX_NAME": { distinct: false }
291
+ * }
292
+ */
293
+ searchParameters?: AgentStudioSearchParameters;
294
+ };
295
+ type DocSearchSidepanelProps = DocSearchCallbacks$1 & {
296
+ /** The assistant ID to use for the ask AI feature. */
297
+ assistantId: string;
298
+ /** Public api key with search permissions for the index. */
299
+ apiKey: string;
300
+ /** Algolia application id used by the search client. */
301
+ appId: string;
302
+ /**
303
+ * The index name to use for the ask AI feature. Your assistant will search
304
+ * this index for relevant documents.
305
+ */
306
+ indexName: string;
307
+ /**
308
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific
309
+ * shortcuts.
310
+ *
311
+ * @default `{ 'Ctrl/Cmd+I': true }`
312
+ */
313
+ keyboardShortcuts?: SidepanelShortcuts;
314
+ /**
315
+ * Theme overrides applied to the Sidepanel button and panel.
316
+ *
317
+ * @default 'light'
318
+ */
319
+ theme?: DocSearchTheme;
320
+ /** Props specific to the Sidepanel button. */
321
+ button?: Omit<SidepanelButtonProps, 'keyboardShortcuts'>;
322
+ /** Props specific to the Sidepanel panel. */
323
+ panel?: Omit<SidepanelProps, 'keyboardShortcuts'>;
324
+ /**
325
+ * Use custom tools driven by Agent Studio.
326
+ *
327
+ * For best performance, memoize this object with `useMemo` or define it
328
+ * outside the component. Inline object literals will be recreated every
329
+ * render but will not affect correctness.
330
+ */
331
+ tools?: ToolCalls;
332
+ /**
333
+ * Configuration for the Agent Studio memory feature.
334
+ *
335
+ * @example
336
+ * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }
337
+ *
338
+ * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview
339
+ */
340
+ memory?: Memory;
341
+ /** List of dynamic indices for the Agent Studio search tool to use. */
342
+ indices?: AgentStudioIndices[];
343
+ };
344
+ declare const DocSearchSidepanel: React.ForwardRefExoticComponent<DocSearchCallbacks$1 & {
345
+ /** The assistant ID to use for the ask AI feature. */
346
+ assistantId: string;
347
+ /** Public api key with search permissions for the index. */
348
+ apiKey: string;
349
+ /** Algolia application id used by the search client. */
350
+ appId: string;
351
+ /**
352
+ * The index name to use for the ask AI feature. Your assistant will search
353
+ * this index for relevant documents.
354
+ */
355
+ indexName: string;
356
+ /**
357
+ * Configuration for keyboard shortcuts. Allows enabling/disabling specific
358
+ * shortcuts.
359
+ *
360
+ * @default `{ 'Ctrl/Cmd+I': true }`
361
+ */
362
+ keyboardShortcuts?: SidepanelShortcuts;
363
+ /**
364
+ * Theme overrides applied to the Sidepanel button and panel.
365
+ *
366
+ * @default 'light'
367
+ */
368
+ theme?: DocSearchTheme;
369
+ /** Props specific to the Sidepanel button. */
370
+ button?: Omit<SidepanelButtonProps, "keyboardShortcuts">;
371
+ /** Props specific to the Sidepanel panel. */
372
+ panel?: Omit<SidepanelProps, "keyboardShortcuts">;
373
+ /**
374
+ * Use custom tools driven by Agent Studio.
375
+ *
376
+ * For best performance, memoize this object with `useMemo` or define it
377
+ * outside the component. Inline object literals will be recreated every
378
+ * render but will not affect correctness.
379
+ */
380
+ tools?: ToolCalls;
381
+ /**
382
+ * Configuration for the Agent Studio memory feature.
383
+ *
384
+ * @example
385
+ * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }
386
+ *
387
+ * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview
388
+ */
389
+ memory?: Memory;
390
+ /** List of dynamic indices for the Agent Studio search tool to use. */
391
+ indices?: AgentStudioIndices[];
392
+ } & SidepanelSearchParameters & React.RefAttributes<DocSearchRef$1>>;
393
+ //#endregion
394
+ export { ButtonVariant, type DocSearchCallbacks, type DocSearchRef, DocSearchSidepanel, DocSearchSidepanelProps, Sidepanel, SidepanelButton, SidepanelButtonProps, SidepanelButtonTranslations, SidepanelProps, SidepanelRef, SidepanelSearchParameters, SidepanelTranslations };
395
+ //# sourceMappingURL=sidepanel.d.ts.map