instantsearch-ui-components
Version:
Common UI components for InstantSearch.
51 lines (50 loc) • 1.88 kB
TypeScript
/** @jsx createElement */
import type { ComponentProps, Renderer } from '../../types';
export type ChatMessageErrorTranslations = {
/**
* Error message text
*/
errorMessage: string | ((params: {
errorMessage?: string;
}) => string);
/**
* New conversation button text
*/
newConversationText: string;
/**
* Retry button text (used when `onReload` is provided and no
* `onNewConversation` / `actions` override it).
*/
retryText: string;
};
export type ChatMessageErrorProps = ComponentProps<'article'> & {
/**
* Raw error message received from the API/transport layer.
*/
errorMessage?: string;
/**
* Callback for retry action. When provided (and no `actions` /
* `onNewConversation` override it), the component renders a default
* "Retry" button. Suitable for transient failures where the same request
* may succeed if re-issued.
*/
onReload?: () => void;
/**
* Callback that clears the current conversation and starts a new one. When
* provided (and no custom `actions` are passed), the component renders a
* default "Start a new conversation" button — recommended for
* guardrails-style errors where retrying the same request will fail again.
* Takes precedence over `onReload` when both are provided.
*/
onNewConversation?: () => void;
/**
* Custom action buttons. When provided, takes precedence over both the
* default `onNewConversation` and `onReload` buttons.
*/
actions?: Array<ComponentProps<'button'>>;
/**
* Translations for error component texts
*/
translations?: Partial<ChatMessageErrorTranslations>;
};
export declare function createChatMessageErrorComponent({ createElement, }: Pick<Renderer, 'createElement'>): (userProps: ChatMessageErrorProps) => JSX.Element;