import type { HTMLAttributes } from 'react';
import type { OptionsType } from '@diplodoc/transform/lib/typings';
import type { PopupPlacement } from '@gravity-ui/uikit';
import { ChatStatus } from "../../../types/index.js";
import type { DefaultMessageAction, MessageExtraInfoComponent, TAssistantMessage, TChatMessage, TMessageContent, TMessageMetadata, TUserMessage } from "../../../types/messages.js";
import { type MessageRendererRegistry } from "../../../utils/messageTypeRegistry.js";
import { AlertProps } from "../../atoms/Alert/index.js";
import type { MarkdownRendererMdxOptions } from "../../atoms/MarkdownRenderer/index.js";
import { type RatingBlockProps } from "../../molecules/RatingBlock/RatingBlock.js";
import "./MessageList.css";
export declare enum MessageListQa {
Root = "message-list",
Messages = "message-list-messages"
}
/** Configuration for action popup behavior */
export interface MessageListActionPopupConfig {
/** Override title for all popups (overrides action-specific title) */
title?: string;
/** Override subtitle for all popups (overrides action-specific subtitle) */
subtitle?: string;
/** Override placement for all popups (overrides action-specific placement) */
placement?: PopupPlacement;
/** Additional CSS class for popup */
className?: string;
/** QA/test identifier for popup */
qa?: string;
}
/**
* Grouped MDX/markdown rendering props exposed as a single object on `MessageList` and
* `ChatContainer`. They are destructured back into individual props before being handed to
* the low-level `MessageItem` renderer.
*/
export type MdxProps = {
/** Options for rendering MDX (`@diplodoc/mdx-extension`) in the default message renderers */
mdxOptions?: MarkdownRendererMdxOptions;
/**
* Resolves the extra props forwarded to the root container `div` of each rendered
* markdown block. Called with the concrete message so handlers (e.g. `onClick`) can
* identify the message they belong to.
*/
getMarkdownExtraProps?: (message: TChatMessage) => HTMLAttributes | undefined;
/**
* Resolves the per-message value exposed to MDX components (via `useMdxContext`).
* Called with the concrete message so embedded MDX components can read data
* unique to the message they belong to.
*/
getMdxContext?: (message: TChatMessage) => Record | undefined;
};
export type MessageListProps = {
messages: TChatMessage[];
status?: ChatStatus;
errorMessage?: AlertProps;
loaderMessage?: string;
withLoaderShimmer?: boolean;
onRetry?: () => void;
messageRendererRegistry?: MessageRendererRegistry;
transformOptions?: OptionsType;
shouldParseIncompleteMarkdown?: boolean;
openMarkdownLinksInNewTab?: boolean;
/** Grouped MDX/markdown rendering props (`mdxOptions`, `getMarkdownExtraProps`, `getMdxContext`). */
mdxProps?: MdxProps;
showActionsOnHover?: boolean;
showTimestamp?: boolean;
showAvatar?: boolean;
userActions?: DefaultMessageAction>[];
assistantActions?: DefaultMessageAction>[];
/** Component rendered alongside action buttons for each user message. Receives message as prop. */
userExtraInfo?: MessageExtraInfoComponent>;
/** Component rendered alongside action buttons for each assistant message. Receives message as prop. */
assistantExtraInfo?: MessageExtraInfoComponent>;
/** Array of chat statuses that should display the loader */
loaderStatuses?: ChatStatus[];
className?: string;
qa?: string;
hasPreviousMessages?: boolean;
onLoadPreviousMessages?: () => void;
/** Rating block configuration (for CSAT or other feedback use cases) - renders after messages list */
ratingBlockProps?: RatingBlockProps;
/** Action popup configuration - applies to all action popups */
actionPopupProps?: MessageListActionPopupConfig;
/**
* Enable windowed rendering via react-window for very large histories.
* Off by default to preserve the existing rendering/scroll behavior.
*/
virtualized?: boolean;
/** Last scrollable row rendered after all messages. */
footerContent?: React.ReactNode;
};
export declare function MessageList(props: MessageListProps): import("react/jsx-runtime").JSX.Element;