UNPKG

react-instantsearch

Version:
46 lines (45 loc) 3.75 kB
import { SearchIndexToolType, RecommendToolType } from 'instantsearch.js/es/lib/chat'; import React from 'react'; export { SearchIndexToolType, RecommendToolType }; import type { ChatProps as ChatUiProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools } from 'instantsearch-ui-components'; import type { IndexUiState } from 'instantsearch.js'; import type { UIMessage } from 'instantsearch.js/es/lib/chat'; import type { UseChatOptions } from 'react-instantsearch-core'; export declare function createDefaultTools<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>, getSearchPageURL?: (nextUiState: IndexUiState) => string): UserClientSideTools; type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent']; type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'toggleButtonProps' | 'messagesProps' | 'promptProps' | 'headerComponent' | 'promptComponent'>; type UserToggleButtonProps = Omit<ChatUiProps['toggleButtonProps'], 'open' | 'onClick'>; type UserHeaderProps = Omit<ChatUiProps['headerProps'], 'onClose'>; type UserMessagesProps = Omit<ChatUiProps['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef'>; type UserPromptProps = Omit<ChatUiProps['promptProps'], 'value' | 'onInput' | 'onSubmit' | 'headerComponent' | 'footerComponent'>; export type Tool = UserClientSideTool; export type Tools = UserClientSideTools; export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps, keyof UiProps> & UseChatOptions<TUiMessage> & { itemComponent?: ItemComponent<TObject>; tools?: UserClientSideTools; defaultOpen?: boolean; getSearchPageURL?: (nextUiState: IndexUiState) => string; toggleButtonProps?: UserToggleButtonProps; headerProps?: UserHeaderProps; messagesProps?: UserMessagesProps; promptProps?: UserPromptProps; toggleButtonComponent?: ChatUiProps['toggleButtonComponent']; toggleButtonIconComponent?: ChatUiProps['toggleButtonProps']['toggleIconComponent']; headerComponent?: ChatUiProps['headerComponent']; headerTitleIconComponent?: ChatUiProps['headerProps']['titleIconComponent']; headerCloseIconComponent?: ChatUiProps['headerProps']['closeIconComponent']; headerMinimizeIconComponent?: ChatUiProps['headerProps']['minimizeIconComponent']; headerMaximizeIconComponent?: ChatUiProps['headerProps']['maximizeIconComponent']; messagesLoaderComponent?: ChatUiProps['messagesProps']['loaderComponent']; messagesErrorComponent?: ChatUiProps['messagesProps']['errorComponent']; promptComponent?: ChatUiProps['promptComponent']; promptHeaderComponent?: ChatUiProps['promptProps']['headerComponent']; promptFooterComponent?: ChatUiProps['promptProps']['footerComponent']; actionsComponent?: ChatUiProps['messagesProps']['actionsComponent']; translations?: Partial<{ prompt: ChatUiProps['promptProps']['translations']; header: ChatUiProps['headerProps']['translations']; messages: ChatUiProps['messagesProps']['translations']; }>; }; export declare function Chat<TObject extends RecordWithObjectID, TUiMessage extends UIMessage>({ tools: userTools, defaultOpen, toggleButtonProps, headerProps, messagesProps, promptProps, itemComponent, toggleButtonComponent, toggleButtonIconComponent, headerComponent, headerTitleIconComponent, headerCloseIconComponent, headerMinimizeIconComponent, headerMaximizeIconComponent, messagesLoaderComponent, messagesErrorComponent, promptComponent, promptHeaderComponent, promptFooterComponent, actionsComponent, classNames, translations, title, getSearchPageURL, ...props }: ChatProps<TObject, TUiMessage>): React.JSX.Element;