@docsearch/sidepanel-js 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,3 +1,9 @@
1
+ type InitialAskAiMessage = {
2
+ query: string;
3
+ messageId?: string;
4
+ suggestedQuestionId?: string;
5
+ };
6
+
1
7
  interface SidepanelShortcuts {
2
8
  /**
3
9
  * Enable/disable the Ctrl/Cmd+I shortcut to toggle the DocSearch sidepanel.
@@ -290,11 +296,37 @@ type DocSearchSidepanelProps = {
290
296
  panel?: Omit<SidepanelProps$1, 'keyboardShortcuts'>;
291
297
  };
292
298
 
293
- type SidepanelProps = DocSearchSidepanelProps & {
299
+ /**
300
+ * Instance returned by sidepanel() for programmatic control.
301
+ */
302
+ interface SidepanelInstance {
303
+ /** Returns true once the component is mounted and ready. */
304
+ readonly isReady: boolean;
305
+ /** Returns true if the sidepanel is currently open. */
306
+ readonly isOpen: boolean;
307
+ /** Opens the sidepanel, optionally with an initial message. */
308
+ open(initialMessage?: InitialAskAiMessage): void;
309
+ /** Closes the sidepanel. */
310
+ close(): void;
311
+ /** Unmounts the Sidepanel component and cleans up. */
312
+ destroy(): void;
313
+ }
314
+ /**
315
+ * Lifecycle callbacks for the Sidepanel instance.
316
+ */
317
+ interface SidepanelCallbacks {
318
+ /** Called once Sidepanel is mounted and ready for interaction. */
319
+ onReady?: () => void;
320
+ /** Called when the sidepanel opens. */
321
+ onOpen?: () => void;
322
+ /** Called when the sidepanel closes. */
323
+ onClose?: () => void;
324
+ }
325
+ type SidepanelProps = DocSearchSidepanelProps & SidepanelCallbacks & {
294
326
  container: HTMLElement | string;
295
327
  environment?: typeof window;
296
328
  };
297
- declare function sidepanel(props: SidepanelProps): () => void;
329
+ declare function sidepanel(props: SidepanelProps): SidepanelInstance;
298
330
 
299
331
  export { sidepanel as default };
300
- export type { SidepanelProps };
332
+ export type { SidepanelCallbacks, SidepanelInstance, SidepanelProps };