@gravity-ui/aikit 2.30.0 → 2.30.1-beta.67e463d2cd48ff4c1e32a2f22503c003d7bcc4e6.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.
- package/build/cjs/components/organisms/Header/Header.css +25 -0
- package/build/cjs/components/organisms/Header/Header.js +22 -2
- package/build/cjs/components/organisms/Header/Header.js.map +1 -1
- package/build/cjs/components/organisms/Header/i18n/en.json +4 -1
- package/build/cjs/components/organisms/Header/i18n/index.d.ts +4 -4
- package/build/cjs/components/organisms/Header/i18n/ru.json +4 -1
- package/build/cjs/components/organisms/Header/types.d.ts +3 -0
- package/build/cjs/components/organisms/Header/types.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/ChatContainer.css +16 -0
- package/build/cjs/components/pages/ChatContainer/ChatContainer.js +21 -10
- package/build/cjs/components/pages/ChatContainer/ChatContainer.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/types.d.ts +9 -0
- package/build/cjs/components/pages/ChatContainer/types.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/useChatExport.js +46 -17
- package/build/cjs/components/pages/ChatContainer/useChatExport.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/useChatExportFeedbackPosition.d.ts +3 -0
- package/build/cjs/components/pages/ChatContainer/useChatExportFeedbackPosition.js +35 -0
- package/build/cjs/components/pages/ChatContainer/useChatExportFeedbackPosition.js.map +1 -0
- package/build/cjs/components/templates/History/ChatItem.d.ts +4 -1
- package/build/cjs/components/templates/History/ChatItem.js +2 -2
- package/build/cjs/components/templates/History/ChatItem.js.map +1 -1
- package/build/cjs/components/templates/History/History.css +14 -0
- package/build/cjs/components/templates/History/History.js +1 -1
- package/build/cjs/components/templates/History/History.js.map +1 -1
- package/build/cjs/components/templates/History/HistoryList.d.ts +5 -0
- package/build/cjs/components/templates/History/HistoryList.js +17 -5
- package/build/cjs/components/templates/History/HistoryList.js.map +1 -1
- package/build/cjs/components/templates/History/i18n/en.json +3 -1
- package/build/cjs/components/templates/History/i18n/index.d.ts +4 -4
- package/build/cjs/components/templates/History/i18n/ru.json +3 -1
- package/build/cjs/hooks/index.d.ts +1 -0
- package/build/cjs/hooks/index.js +1 -0
- package/build/cjs/hooks/index.js.map +1 -1
- package/build/cjs/hooks/useChatActivity.d.ts +10 -0
- package/build/cjs/hooks/useChatActivity.js +52 -0
- package/build/cjs/hooks/useChatActivity.js.map +1 -0
- package/build/cjs/package.json +1 -1
- package/build/cjs/utils/chatActivity/chatActivityPersistence.d.ts +25 -0
- package/build/cjs/utils/chatActivity/chatActivityPersistence.js +202 -0
- package/build/cjs/utils/chatActivity/chatActivityPersistence.js.map +1 -0
- package/build/cjs/utils/chatActivity/chatActivityStore.d.ts +59 -0
- package/build/cjs/utils/chatActivity/chatActivityStore.js +119 -0
- package/build/cjs/utils/chatActivity/chatActivityStore.js.map +1 -0
- package/build/cjs/utils/chatActivity/index.d.ts +2 -0
- package/build/cjs/utils/chatActivity/index.js +7 -0
- package/build/cjs/utils/chatActivity/index.js.map +1 -0
- package/build/cjs/utils/chatActivity/remoteChatActivityStore.d.ts +38 -0
- package/build/cjs/utils/chatActivity/remoteChatActivityStore.js +137 -0
- package/build/cjs/utils/chatActivity/remoteChatActivityStore.js.map +1 -0
- package/build/cjs/utils/chatMarkdown.js +101 -2
- package/build/cjs/utils/chatMarkdown.js.map +1 -1
- package/build/cjs/utils/index.d.ts +1 -0
- package/build/cjs/utils/index.js +1 -0
- package/build/cjs/utils/index.js.map +1 -1
- package/build/docs/INDEX.md +1 -0
- package/build/docs/components/organisms/Header.md +5 -0
- package/build/docs/components/pages/ChatContainer.md +16 -4
- package/build/docs/components/templates/History.md +6 -0
- package/build/docs/guides/chat-activity.md +160 -0
- package/build/esm/components/organisms/Header/Header.css +25 -0
- package/build/esm/components/organisms/Header/Header.js +23 -3
- package/build/esm/components/organisms/Header/Header.js.map +1 -1
- package/build/esm/components/organisms/Header/i18n/en.json +4 -1
- package/build/esm/components/organisms/Header/i18n/index.d.ts +4 -4
- package/build/esm/components/organisms/Header/i18n/ru.json +4 -1
- package/build/esm/components/organisms/Header/types.d.ts +3 -0
- package/build/esm/components/organisms/Header/types.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/ChatContainer.css +16 -0
- package/build/esm/components/pages/ChatContainer/ChatContainer.js +22 -11
- package/build/esm/components/pages/ChatContainer/ChatContainer.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/types.d.ts +9 -0
- package/build/esm/components/pages/ChatContainer/types.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/useChatExport.js +47 -18
- package/build/esm/components/pages/ChatContainer/useChatExport.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/useChatExportFeedbackPosition.d.ts +3 -0
- package/build/esm/components/pages/ChatContainer/useChatExportFeedbackPosition.js +32 -0
- package/build/esm/components/pages/ChatContainer/useChatExportFeedbackPosition.js.map +1 -0
- package/build/esm/components/templates/History/ChatItem.d.ts +4 -1
- package/build/esm/components/templates/History/ChatItem.js +3 -3
- package/build/esm/components/templates/History/ChatItem.js.map +1 -1
- package/build/esm/components/templates/History/History.css +14 -0
- package/build/esm/components/templates/History/History.js +1 -1
- package/build/esm/components/templates/History/History.js.map +1 -1
- package/build/esm/components/templates/History/HistoryList.d.ts +5 -0
- package/build/esm/components/templates/History/HistoryList.js +17 -5
- package/build/esm/components/templates/History/HistoryList.js.map +1 -1
- package/build/esm/components/templates/History/i18n/en.json +3 -1
- package/build/esm/components/templates/History/i18n/index.d.ts +4 -4
- package/build/esm/components/templates/History/i18n/ru.json +3 -1
- package/build/esm/hooks/index.d.ts +1 -0
- package/build/esm/hooks/index.js +1 -0
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useChatActivity.d.ts +10 -0
- package/build/esm/hooks/useChatActivity.js +49 -0
- package/build/esm/hooks/useChatActivity.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/utils/chatActivity/chatActivityPersistence.d.ts +25 -0
- package/build/esm/utils/chatActivity/chatActivityPersistence.js +199 -0
- package/build/esm/utils/chatActivity/chatActivityPersistence.js.map +1 -0
- package/build/esm/utils/chatActivity/chatActivityStore.d.ts +59 -0
- package/build/esm/utils/chatActivity/chatActivityStore.js +114 -0
- package/build/esm/utils/chatActivity/chatActivityStore.js.map +1 -0
- package/build/esm/utils/chatActivity/index.d.ts +2 -0
- package/build/esm/utils/chatActivity/index.js +4 -0
- package/build/esm/utils/chatActivity/index.js.map +1 -0
- package/build/esm/utils/chatActivity/remoteChatActivityStore.d.ts +38 -0
- package/build/esm/utils/chatActivity/remoteChatActivityStore.js +134 -0
- package/build/esm/utils/chatActivity/remoteChatActivityStore.js.map +1 -0
- package/build/esm/utils/chatMarkdown.js +101 -2
- package/build/esm/utils/chatMarkdown.js.map +1 -1
- package/build/esm/utils/index.d.ts +1 -0
- package/build/esm/utils/index.js +1 -0
- package/build/esm/utils/index.js.map +1 -1
- package/docs/chat-activity.md +160 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainer.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/ChatContainer.tsx"],"names":[],"mappings":";;AAsMA,sCA+jBC;;;AArwBD,iCAAiG;AAEjG,6CAA+E;AAE/E,mDAA8E;AAE9E,6CAAwC;AACxC,qDAAkG;AAClG,gEAAkD;AAClD,4DAA8E;AAC9E,sEAIqC;AACrC,4EAAoE;AACpE,8DAAgD;AAEhD,4DAAoD;AACpD,sDAAsD;AACtD,0DAK2B;AAC3B,0CAA4B;AAE5B,4DAAoD;AACpD,wEAAgE;AAChE,sDAA8C;AAC9C,oEAA4D;AAE5D,+BAA8B;AAE9B,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,gBAAgB,CAAC,CAAC;AAClC,MAAM,qBAAqB,GAAiB,EAAE,CAAC;AAI/C,SAAS,mBAAmB,CACxB,EAAW,EACX,IAA8B;IAE9B,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI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eAAM,oBACC,gBAAgB,IACpB,SAAS,EAAE,CAAC,GAAG,CAAC,MAAA,gBAAgB,CAAC,SAAS,mCAAI,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,IAC7E,EACD,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,cAAc,IAC7C,EACN,gCAAK,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,SAAS,CAAC,eAAe,EAAC,EAAE,gBAAgB,CAAC,YAC7E,uBAAC,yBAAW,oBAAK,iBAAiB,EAAI,GACpC,EACL,UAAU,IAAI,CACX,iCACI,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,SAAS,CAAC,eAAe,EAAC,EAAE,eAAe,CAAC,EAC1E,GAAG,EAAE,SAAS,aAEb,qBAAqB,IAAI,CACtB,uBAAC,yBAAW,oBAEJ,qBAAqB,GADpB,SAAS,CAAC,cAAc,CAE/B,CACL,EACA,oBAAoB,IAAI,uBAAC,uBAAU,oBAAK,oBAAoB,EAAI,IAC/D,CACT,EAED,uBAAC,iBAAO,oBAAK,iBAAiB,EAAI,EACjC,KAAK,CAAC,UAAU,IAAI,CACjB,uBAAC,mCAAgB,oBAAK,UAAU,CAAC,WAAW,IAAE,QAAQ,EAAE,cAAc,IAAI,CAC7E,IACC,GACO,CACpB,CAAC;AACN,CAAC","sourcesContent":["import {type CSSProperties, Fragment, type ReactNode, useCallback, useMemo, useRef} from 'react';\n\nimport {Alert, MobileProvider, useForkRef, useMobile} from '@gravity-ui/uikit';\n\nimport {getMascotAnimationType, useKeyboardViewportFit} from '../../../hooks';\nimport type {TSuggestionContext} from '../../../types/messages';\nimport {block} from '../../../utils/cn';\nimport {getMascotNode, resolveMascotAssets, resolveMascotCollection} from '../../../utils/mascot';\nimport {Disclaimer} from '../../atoms/Disclaimer';\nimport {Header, HeaderAction, type HeaderProps} from '../../organisms/Header';\nimport {\n PromptInput,\n type PromptInputHandle,\n type PromptInputProps,\n} from '../../organisms/PromptInput';\nimport {ChatContent} from '../../templates/ChatContent/ChatContent';\nimport {History} from '../../templates/History';\n\nimport {ChatExportDialog} from './ChatExportDialog';\nimport {defaultGravityMascots} from './GravityMascot';\nimport {\n normalizeChatContainerQa,\n resolveChatContainerQa,\n resolveChatContainerRootQa,\n resolveHeaderMenuItemQa,\n} from './chatContainerQa';\nimport {i18n} from './i18n';\nimport type {ChatContainerProps, ChatContainerTexts, MascotConfig} from './types';\nimport {useChatContainer} from './useChatContainer';\nimport {useChatContainerMascot} from './useChatContainerMascot';\nimport {useChatExport} from './useChatExport';\nimport {useKeyboardLayoutFit} from './useKeyboardLayoutFit';\n\nimport './ChatContainer.scss';\n\nconst b = block('chat-container');\nconst DEFAULT_MASCOT_CONFIG: MascotConfig = {};\n\ntype NormalizedChatContainerQa = ReturnType<typeof normalizeChatContainerQa>;\n\nfunction toSuggestionContext(\n id?: string,\n data?: Record<string, unknown>,\n): TSuggestionContext | undefined {\n if (!id && !data) {\n return undefined;\n }\n\n return {\n ...(id && {id}),\n ...(data && {data}),\n };\n}\n\nfunction mergePromptInputSuggestionsProps(\n fromProps: PromptInputProps['suggestionsProps'] | undefined,\n textsSuggestTitle: ReactNode | undefined,\n): PromptInputProps['suggestionsProps'] | undefined {\n const hasSuggestionsFromProps = Boolean(fromProps);\n const hasSuggestTitleFromTexts = textsSuggestTitle !== undefined;\n if (!hasSuggestionsFromProps && !hasSuggestTitleFromTexts) {\n return undefined;\n }\n return {\n ...fromProps,\n suggestTitle: textsSuggestTitle ?? fromProps?.suggestTitle,\n };\n}\n\nfunction buildFinalPromptInputHeaderProps(args: {\n headerProps: NonNullable<ChatContainerProps['promptInputProps']>['headerProps'];\n contextItems: ChatContainerProps['contextItems'];\n showContextIndicator: ChatContainerProps['showContextIndicator'];\n contextIndicatorProps: ChatContainerProps['contextIndicatorProps'];\n qa: string | undefined;\n}): NonNullable<ChatContainerProps['promptInputProps']>['headerProps'] {\n const {headerProps, contextItems, showContextIndicator, contextIndicatorProps, qa} = args;\n\n // topContent replaces the default header entirely, so context-related\n // props are not allowed (and would be ignored) alongside it\n if (headerProps?.topContent) {\n return {topContent: headerProps.topContent, qa};\n }\n\n return {\n contextItems,\n showContextIndicator: showContextIndicator ?? headerProps?.showContextIndicator,\n contextIndicatorProps: contextIndicatorProps ?? headerProps?.contextIndicatorProps,\n qa,\n };\n}\n\nfunction buildFinalPromptInputProps(args: {\n promptInputProps: ChatContainerProps['promptInputProps'];\n onSendMessage: ChatContainerProps['onSendMessage'];\n onCancel: ChatContainerProps['onCancel'];\n status: ChatContainerProps['status'];\n contextItems: ChatContainerProps['contextItems'];\n showContextIndicator: ChatContainerProps['showContextIndicator'];\n contextIndicatorProps: ChatContainerProps['contextIndicatorProps'];\n texts: ChatContainerTexts;\n promptInputKey: number;\n commandsResetKey: string | number;\n qaMap: NormalizedChatContainerQa;\n onValueChange?: (value: string) => void;\n}) {\n const {\n promptInputProps,\n onSendMessage,\n onCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n texts: textsArg,\n promptInputKey,\n commandsResetKey,\n qaMap,\n onValueChange,\n } = args;\n\n const texts = textsArg ?? {};\n\n const {\n autoFocusOnNewChat: _autoFocusOnNewChat,\n autoFocusOnChatSelect: _autoFocusOnChatSelect,\n ...restBodyProps\n } = promptInputProps?.bodyProps ?? {};\n\n const suggestionsProps = mergePromptInputSuggestionsProps(\n promptInputProps?.suggestionsProps,\n texts.promptSuggestTitle,\n );\n\n return {\n ...promptInputProps,\n commandsResetKey,\n onValueChange:\n onValueChange || promptInputProps?.onValueChange\n ? (value: string) => {\n onValueChange?.(value);\n promptInputProps?.onValueChange?.(value);\n }\n : undefined,\n qa: resolveChatContainerQa(qaMap, 'promptInput', 'prompt-input') ?? promptInputProps?.qa,\n onSend: onSendMessage,\n onCancel,\n status,\n suggestionsProps,\n headerProps: buildFinalPromptInputHeaderProps({\n headerProps: promptInputProps?.headerProps,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputHeader', 'prompt-input-header') ??\n promptInputProps?.headerProps?.qa,\n }),\n bodyProps: {\n ...restBodyProps,\n placeholder:\n texts.promptPlaceholder || restBodyProps?.placeholder || i18n('prompt-placeholder'),\n // The remount that clears the draft on a new or a freshly picked chat also puts the\n // cursor in the field. On a touch device that raises the keyboard over half the\n // screen, so a consumer that asked for no auto focus is taken at its word and keeps\n // the clearing without the cursor.\n autoFocus: restBodyProps?.autoFocus ?? promptInputKey > 0,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputBody', 'prompt-input-body') ??\n restBodyProps?.qa,\n },\n footerProps: {\n ...promptInputProps?.footerProps,\n submitButtonTooltipSend:\n texts?.submitSendTooltip ?? promptInputProps?.footerProps?.submitButtonTooltipSend,\n submitButtonTooltipCancel:\n texts?.submitCancelTooltip ??\n promptInputProps?.footerProps?.submitButtonTooltipCancel,\n submitButtonCancelableText:\n texts?.submitButtonCancelableText ??\n promptInputProps?.footerProps?.submitButtonCancelableText,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputFooter', 'prompt-input-footer') ??\n promptInputProps?.footerProps?.qa,\n submitButtonQa:\n resolveChatContainerQa(qaMap, 'submitButton', 'submit-button') ??\n promptInputProps?.footerProps?.submitButtonQa,\n },\n };\n}\n\n/**\n * ChatContainer - fully assembled chat component, the main exportable component of the library.\n * Integrates Header, ChatContent, History and manages their state.\n *\n * @param props - component props\n * @returns React component\n */\nexport function ChatContainer(props: ChatContainerProps) {\n const {\n chats = [],\n messages = [],\n onSendMessage,\n onDeleteChat,\n onCancel,\n onRetry,\n status = 'ready',\n error = null,\n showActionsOnHover = false,\n contextItems = [],\n showContextIndicator,\n contextIndicatorProps,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n messageListConfig,\n showMascot = false,\n mascotConfig: customMascotConfig,\n headerProps = {},\n contentProps = {},\n emptyContainerProps = {},\n promptInputProps = {},\n disclaimerProps = {},\n historyProps = {},\n welcomeConfig,\n texts = {},\n hideTitleOnEmptyChat = false,\n isMobile: isMobileProp,\n adjustToKeyboard = true,\n floatingHeader = false,\n className,\n headerClassName,\n contentClassName,\n footerClassName,\n qa,\n } = props;\n\n const isMobileContext = useMobile();\n const isMobile = isMobileProp ?? isMobileContext;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const viewportProbeRef = useRef<HTMLDivElement>(null);\n const isKeyboardTracked = isMobile && adjustToKeyboard;\n // Keeps the footer (prompt input + disclaimer) above the on-screen keyboard on iOS Safari,\n // where the layout viewport stays full-height while the keyboard is open.\n const {isKeyboardOpen, maxHeight} = useKeyboardViewportFit(rootRef, isKeyboardTracked, {\n viewportProbeRef,\n });\n // Measured at all times, not only while the keyboard is open: otherwise the field grows by\n // its own row counter while the keyboard is away, and by the next time it comes back the\n // field is already taller than the space left, with the cap long gone.\n const {promptInputMaxHeight, isHeroFitting} = useKeyboardLayoutFit(\n rootRef,\n headerRef,\n footerRef,\n isKeyboardTracked,\n );\n\n const hookState = useChatContainer(props);\n const chatExport = useChatExport({\n conversationKey: hookState.chatExportKey,\n chatId: props.activeChat?.id,\n messages,\n status,\n config: props.chatExport,\n });\n const exportFeedback = chatExport.notice && (\n <div role=\"status\">\n <Alert\n theme={chatExport.notice.error ? 'danger' : 'success'}\n message={chatExport.notice.text}\n onClose={chatExport.dismissNotice}\n />\n </div>\n );\n\n const mascotConfig = customMascotConfig ?? (showMascot ? DEFAULT_MASCOT_CONFIG : undefined);\n const mascotState = useChatContainerMascot({\n config: mascotConfig,\n view: hookState.chatContentView === 'empty' ? 'hero' : 'chat',\n status,\n messagesCount: messages.length,\n activeChatId: hookState.activeChat?.id,\n promptInputKey: hookState.promptInputKey,\n });\n\n const promptApiRef = useRef<PromptInputHandle>(null);\n const mergedPromptApiRef = useForkRef(promptApiRef, promptInputProps?.apiRef);\n\n const wrappedOnSendMessage = useCallback(\n async (...args: Parameters<typeof onSendMessage>) => {\n mascotState.notifyActivity();\n return onSendMessage(...args);\n },\n [mascotState.notifyActivity, onSendMessage],\n );\n const wrappedOnCancel = useMemo(() => {\n if (!onCancel) {\n return undefined;\n }\n return async () => {\n await onCancel();\n mascotState.handleCancelResolved();\n };\n }, [mascotState.handleCancelResolved, onCancel]);\n const wrappedOnRetry = useMemo(() => {\n if (!onRetry) {\n return undefined;\n }\n return () => {\n mascotState.notifyActivity();\n onRetry();\n };\n }, [mascotState.notifyActivity, onRetry]);\n\n const resolvedMascotAssets = useMemo(\n () => resolveMascotAssets(mascotConfig?.defaultAssets, mascotConfig?.assets),\n [mascotConfig?.assets, mascotConfig?.defaultAssets],\n );\n const resolvedMascots = useMemo(\n () =>\n resolveMascotCollection(\n resolveMascotCollection(\n showMascot ? defaultGravityMascots : undefined,\n mascotConfig?.defaultMascots,\n ),\n mascotConfig?.mascots,\n ),\n [showMascot, mascotConfig?.defaultMascots, mascotConfig?.mascots],\n );\n const mascotView = hookState.chatContentView === 'empty' ? 'hero' : 'chat';\n const mascotNode = useMemo(() => {\n if (!mascotConfig) {\n return undefined;\n }\n if (mascotView === 'hero' && mascotConfig.showOnWelcome === false) {\n return undefined;\n }\n if (mascotView === 'chat' && mascotConfig.showInChat === false) {\n return undefined;\n }\n const node = mascotConfig.renderMascot\n ? mascotConfig.renderMascot({\n view: mascotView,\n state: mascotState.state,\n animationType: getMascotAnimationType(mascotState.state),\n assets: resolvedMascotAssets,\n })\n : getMascotNode(resolvedMascots, mascotView, mascotState.state);\n if (node === undefined || node === null) {\n return undefined;\n }\n return <div className={b('mascot', {view: mascotView})}>{node}</div>;\n }, [mascotConfig, mascotState.state, mascotView, resolvedMascotAssets, resolvedMascots]);\n\n const qaMap = useMemo(() => normalizeChatContainerQa(qa), [qa]);\n\n // Collect i18n texts with overrides\n const headerTitle = useMemo(\n () =>\n texts.headerTitle ||\n headerProps.title ||\n hookState.activeChat?.name ||\n i18n('header-default-title'),\n [texts.headerTitle, headerProps.title, hookState.activeChat?.name],\n );\n\n // Determine if chat is empty\n const isChatEmpty = hookState.chatContentView === 'empty';\n\n // Calculate showTitle based on hideTitleOnEmptyChat option\n const showTitle = useMemo(() => {\n // If explicit showTitle is provided in headerProps, use it\n if (headerProps.showTitle !== undefined) {\n return headerProps.showTitle;\n }\n // If hideTitleOnEmptyChat is enabled, show title only when chat has messages\n if (hideTitleOnEmptyChat && isChatEmpty) {\n return false;\n }\n return true;\n }, [hideTitleOnEmptyChat, isChatEmpty, headerProps.showTitle]);\n\n // Build props for Header\n const finalHeaderProps = useMemo(() => {\n const actionQa: Partial<Record<HeaderAction, string>> = {\n ...headerProps.actionQa,\n };\n const setHeaderActionQa = (\n action: HeaderAction,\n key: 'headerNewChat' | 'headerHistory' | 'headerFolding' | 'headerClose',\n suffix: string,\n ) => {\n const resolved = resolveChatContainerQa(qaMap, key, suffix);\n if (resolved !== undefined) {\n actionQa[action] = resolved;\n }\n };\n setHeaderActionQa(HeaderAction.NewChat, 'headerNewChat', 'header-action-newChat');\n setHeaderActionQa(HeaderAction.History, 'headerHistory', 'header-action-history');\n setHeaderActionQa(HeaderAction.Folding, 'headerFolding', 'header-action-folding');\n setHeaderActionQa(HeaderAction.Close, 'headerClose', 'header-action-close');\n\n const actionTooltipTexts: NonNullable<HeaderProps['actionTooltipTexts']> = {\n [HeaderAction.NewChat]:\n texts.headerNewChatTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.NewChat],\n [HeaderAction.History]:\n texts.headerHistoryTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.History],\n [HeaderAction.Close]:\n texts.headerCloseTooltip ?? headerProps.actionTooltipTexts?.[HeaderAction.Close],\n [HeaderAction.Folding]: {\n collapsed:\n texts.headerFoldingCollapsedTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.Folding]?.collapsed,\n opened:\n texts.headerFoldingOpenedTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.Folding]?.opened,\n },\n };\n\n return {\n ...headerProps,\n title: headerTitle,\n showTitle,\n baseActions: hookState.baseActions,\n handleNewChat: hookState.handleNewChat,\n handleHistoryToggle: hookState.handleHistoryToggle,\n handleFolding: hookState.handleFolding,\n handleClose: hookState.handleClose,\n historyButtonRef: hookState.historyButtonRef,\n qa: resolveChatContainerQa(qaMap, 'header', 'header') ?? headerProps.qa,\n actionQa,\n actionTooltipTexts,\n menuButtonQa:\n resolveChatContainerQa(qaMap, 'headerMenuButton', 'header-menu-button') ??\n headerProps.menuButtonQa,\n menuButtonTooltip: texts.headerMenuTooltip ?? headerProps.menuButtonTooltip,\n menuItemQa: resolveHeaderMenuItemQa(\n qaMap,\n headerProps.menuItems,\n headerProps.menuItemQa,\n ),\n };\n }, [\n headerTitle,\n showTitle,\n hookState.baseActions,\n hookState.handleNewChat,\n hookState.handleHistoryToggle,\n hookState.handleFolding,\n hookState.handleClose,\n hookState.historyButtonRef,\n headerProps,\n qaMap,\n texts.headerNewChatTooltip,\n texts.headerHistoryTooltip,\n texts.headerCloseTooltip,\n texts.headerFoldingCollapsedTooltip,\n texts.headerFoldingOpenedTooltip,\n texts.headerMenuTooltip,\n ]);\n\n // Build props for EmptyContainer\n const finalEmptyContainerProps = useMemo(() => {\n const {showDefaultTitle = true, showDefaultDescription = true} = welcomeConfig || {};\n\n return {\n ...emptyContainerProps,\n qa:\n resolveChatContainerQa(qaMap, 'emptyState', 'empty-state') ??\n emptyContainerProps.qa,\n image: welcomeConfig?.image,\n title:\n texts.emptyStateTitle ??\n welcomeConfig?.title ??\n emptyContainerProps.title ??\n (showDefaultTitle ? i18n('empty-state-title') : undefined),\n description:\n texts.emptyStateDescription ??\n welcomeConfig?.description ??\n emptyContainerProps.description ??\n (showDefaultDescription ? i18n('empty-state-description') : undefined),\n suggestionTitle:\n texts.emptyStateSuggestionsTitle ??\n welcomeConfig?.suggestionTitle ??\n emptyContainerProps.suggestionTitle,\n suggestions: welcomeConfig?.suggestions,\n alignment: {\n ...emptyContainerProps.alignment,\n ...welcomeConfig?.alignment,\n ...(mascotView === 'hero' &&\n mascotNode &&\n emptyContainerProps.alignment?.hero === undefined &&\n welcomeConfig?.alignment?.hero === undefined\n ? {hero: 'center' as const}\n : {}),\n },\n heroContent:\n emptyContainerProps.heroContent ?? (mascotView === 'hero' ? mascotNode : undefined),\n layout: welcomeConfig?.layout ?? emptyContainerProps.layout,\n wrapText: welcomeConfig?.wrapText ?? emptyContainerProps.wrapText,\n showMore: welcomeConfig?.showMore,\n showMoreText:\n texts.emptyStateShowMoreText ??\n welcomeConfig?.showMoreText ??\n emptyContainerProps.showMoreText ??\n i18n('empty-state-show-more'),\n onSuggestionClick: async (\n content: string,\n suggestionId?: string,\n suggestionData?: Record<string, unknown>,\n ) => {\n const suggestion = toSuggestionContext(suggestionId, suggestionData);\n\n await promptApiRef.current?.submit({\n content,\n ...(suggestion && {suggestion}),\n });\n },\n };\n }, [\n welcomeConfig,\n emptyContainerProps,\n wrappedOnSendMessage,\n qaMap,\n texts.emptyStateTitle,\n texts.emptyStateDescription,\n texts.emptyStateSuggestionsTitle,\n texts.emptyStateShowMoreText,\n mascotNode,\n mascotView,\n ]);\n\n // Build props for MessageList\n const messageListProps = useMemo(\n () => ({\n ...messageListConfig,\n messages,\n status,\n errorMessage: texts.errorText\n ? {...(messageListConfig?.errorMessage ?? {}), text: texts.errorText}\n : messageListConfig?.errorMessage || (error ? {text: error.message} : undefined),\n onRetry: wrappedOnRetry,\n showActionsOnHover,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n qa:\n resolveChatContainerQa(qaMap, 'messageList', 'message-list') ??\n messageListConfig?.qa,\n actionPopupProps: {\n ...messageListConfig?.actionPopupProps,\n qa:\n resolveChatContainerQa(qaMap, 'actionPopup', 'action-popup') ??\n messageListConfig?.actionPopupProps?.qa,\n },\n footerContent:\n mascotView === 'chat' && mascotNode !== undefined && mascotNode !== null ? (\n <Fragment>\n {messageListConfig?.footerContent}\n {mascotNode}\n </Fragment>\n ) : (\n messageListConfig?.footerContent\n ),\n }),\n [\n messages,\n status,\n error,\n wrappedOnRetry,\n showActionsOnHover,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n messageListConfig,\n qaMap,\n texts.errorText,\n mascotNode,\n mascotView,\n ],\n );\n\n // Build props for PromptInput\n const finalPromptInputProps = useMemo(\n () =>\n buildFinalPromptInputProps({\n promptInputProps: {...promptInputProps, apiRef: mergedPromptApiRef},\n onSendMessage: wrappedOnSendMessage,\n onCancel: wrappedOnCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n texts,\n promptInputKey: hookState.promptInputKey,\n commandsResetKey: hookState.commandsResetKey,\n qaMap,\n onValueChange: mascotConfig ? mascotState.handleValueChange : undefined,\n }),\n [\n wrappedOnSendMessage,\n wrappedOnCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n promptInputProps,\n mergedPromptApiRef,\n hookState.promptInputKey,\n hookState.commandsResetKey,\n qaMap,\n texts.promptPlaceholder,\n texts.promptSuggestTitle,\n texts.submitSendTooltip,\n texts.submitCancelTooltip,\n texts.submitButtonCancelableText,\n mascotState.handleValueChange,\n mascotConfig,\n ],\n );\n\n // Build props for Disclaimer\n const finalDisclaimerProps = useMemo(() => {\n const disclaimerText =\n texts.disclaimerText ?? disclaimerProps.text ?? i18n('disclaimer-text');\n\n return {\n ...disclaimerProps,\n text: disclaimerText,\n qa: resolveChatContainerQa(qaMap, 'disclaimer', 'disclaimer') ?? disclaimerProps.qa,\n };\n }, [disclaimerProps, qaMap, texts.disclaimerText]);\n\n // Build props for ChatContent\n const finalContentProps = useMemo(\n () => ({\n ...contentProps,\n qa: resolveChatContainerQa(qaMap, 'content', 'content') ?? contentProps.qa,\n view: hookState.chatContentView as 'empty' | 'chat',\n emptyContainerProps: finalEmptyContainerProps,\n messageListProps,\n }),\n [\n hookState.chatContentView,\n finalEmptyContainerProps,\n messageListProps,\n contentProps,\n qaMap,\n ],\n );\n\n // Build props for History\n const finalHistoryProps = useMemo(\n () => ({\n ...historyProps,\n qa: resolveChatContainerQa(qaMap, 'history', 'history') ?? historyProps.qa,\n chats,\n selectedChat: hookState.activeChat,\n onSelectChat: hookState.handleSelectChat,\n onDeleteChat,\n open: hookState.isHistoryOpen,\n onOpenChange: (open: boolean) => {\n historyProps.onOpenChange?.(open);\n hookState.handleHistoryOpenChange(open);\n },\n anchorElement: hookState.historyButtonRef.current,\n emptyPlaceholder:\n texts.historyEmptyPlaceholder ??\n historyProps.emptyPlaceholder ??\n i18n('history-empty'),\n emptyFilteredPlaceholder:\n texts.historyEmptyFilteredPlaceholder ??\n historyProps.emptyFilteredPlaceholder ??\n i18n('history-empty-filtered'),\n searchPlaceholder: texts.historySearchPlaceholder ?? historyProps.searchPlaceholder,\n }),\n [\n chats,\n hookState.activeChat,\n hookState.handleSelectChat,\n onDeleteChat,\n hookState.isHistoryOpen,\n hookState.handleHistoryOpenChange,\n hookState.historyButtonRef,\n historyProps,\n qaMap,\n texts.historyEmptyPlaceholder,\n texts.historyEmptyFilteredPlaceholder,\n texts.historySearchPlaceholder,\n ],\n );\n\n const showFooter = finalPromptInputProps || finalDisclaimerProps;\n\n const rootStyle = useMemo<CSSProperties | undefined>(() => {\n if (maxHeight === undefined && promptInputMaxHeight === undefined && isHeroFitting) {\n return undefined;\n }\n\n return {\n ...(maxHeight === undefined ? undefined : {maxHeight}),\n ...(promptInputMaxHeight === undefined\n ? undefined\n : {\n '--g-aikit-prompt-input-body-textarea-max-height': `${promptInputMaxHeight}px`,\n }),\n ...(isHeroFitting\n ? undefined\n : {'--g-aikit-empty-container-hero-visibility': 'hidden'}),\n } as CSSProperties;\n }, [maxHeight, promptInputMaxHeight, isHeroFitting]);\n\n return (\n <MobileProvider mobile={isMobile}>\n <div\n ref={rootRef}\n className={b(\n {\n mobile: isMobile,\n 'keyboard-open': isKeyboardOpen,\n 'floating-header': floatingHeader,\n },\n className,\n )}\n style={rootStyle}\n data-qa={resolveChatContainerRootQa(qaMap)}\n >\n {isKeyboardTracked && (\n <div className={b('viewport-probe')} ref={viewportProbeRef} aria-hidden />\n )}\n <div className={b('header', headerClassName)} ref={headerRef}>\n <Header\n {...finalHeaderProps}\n menuItems={[...(finalHeaderProps.menuItems ?? []), ...chatExport.menuItems]}\n />\n {!chatExport.dialogProps.open && exportFeedback}\n </div>\n <div className={b('content', {view: hookState.chatContentView}, contentClassName)}>\n <ChatContent {...finalContentProps} />\n </div>\n {showFooter && (\n <div\n className={b('footer', {view: hookState.chatContentView}, footerClassName)}\n ref={footerRef}\n >\n {finalPromptInputProps && (\n <PromptInput\n key={hookState.promptInputKey}\n {...finalPromptInputProps}\n />\n )}\n {finalDisclaimerProps && <Disclaimer {...finalDisclaimerProps} />}\n </div>\n )}\n {/* History is integrated via popup anchored to button in Header */}\n <History {...finalHistoryProps} />\n {props.chatExport && (\n <ChatExportDialog {...chatExport.dialogProps} feedback={exportFeedback} />\n )}\n </div>\n </MobileProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ChatContainer.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/ChatContainer.tsx"],"names":[],"mappings":";;AAwMA,sCAklBC;;;AA1xBD,iCAAiG;AAEjG,6CAAuF;AAEvF,mDAA8E;AAC9E,uEAA+D;AAE/D,6CAAwC;AACxC,qDAAkG;AAClG,gEAAkD;AAClD,4DAA8E;AAC9E,sEAIqC;AACrC,4EAAoE;AACpE,8DAAgD;AAEhD,4DAAoD;AACpD,sDAAsD;AACtD,0DAK2B;AAC3B,0CAA4B;AAE5B,4DAAoD;AACpD,wEAAgE;AAChE,sDAA8C;AAC9C,sFAA8E;AAC9E,oEAA4D;AAE5D,+BAA8B;AAE9B,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,gBAAgB,CAAC,CAAC;AAClC,MAAM,qBAA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EAAI,GACpC,EACL,UAAU,IAAI,CACX,iCACI,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,SAAS,CAAC,eAAe,EAAC,EAAE,eAAe,CAAC,EAC1E,GAAG,EAAE,SAAS,aAEb,qBAAqB,IAAI,CACtB,uBAAC,yBAAW,oBAEJ,qBAAqB,GADpB,SAAS,CAAC,cAAc,CAE/B,CACL,EACA,oBAAoB,IAAI,uBAAC,uBAAU,oBAAK,oBAAoB,EAAI,IAC/D,CACT,EAED,uBAAC,iBAAO,oBAAK,iBAAiB,EAAI,EACjC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,cAAc,EAC9C,KAAK,CAAC,UAAU,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,CAChD,uBAAC,mCAAgB,oBAAK,UAAU,CAAC,WAAW,IAAE,QAAQ,EAAE,cAAc,IAAI,CAC7E,IACC,GACO,CACpB,CAAC;AACN,CAAC","sourcesContent":["import {type CSSProperties, Fragment, type ReactNode, useCallback, useMemo, useRef} from 'react';\n\nimport {Alert, MobileProvider, Portal, useForkRef, useMobile} from '@gravity-ui/uikit';\n\nimport {getMascotAnimationType, useKeyboardViewportFit} from '../../../hooks';\nimport {useChatActivity} from '../../../hooks/useChatActivity';\nimport type {TSuggestionContext} from '../../../types/messages';\nimport {block} from '../../../utils/cn';\nimport {getMascotNode, resolveMascotAssets, resolveMascotCollection} from '../../../utils/mascot';\nimport {Disclaimer} from '../../atoms/Disclaimer';\nimport {Header, HeaderAction, type HeaderProps} from '../../organisms/Header';\nimport {\n PromptInput,\n type PromptInputHandle,\n type PromptInputProps,\n} from '../../organisms/PromptInput';\nimport {ChatContent} from '../../templates/ChatContent/ChatContent';\nimport {History} from '../../templates/History';\n\nimport {ChatExportDialog} from './ChatExportDialog';\nimport {defaultGravityMascots} from './GravityMascot';\nimport {\n normalizeChatContainerQa,\n resolveChatContainerQa,\n resolveChatContainerRootQa,\n resolveHeaderMenuItemQa,\n} from './chatContainerQa';\nimport {i18n} from './i18n';\nimport type {ChatContainerProps, ChatContainerTexts, MascotConfig} from './types';\nimport {useChatContainer} from './useChatContainer';\nimport {useChatContainerMascot} from './useChatContainerMascot';\nimport {useChatExport} from './useChatExport';\nimport {useChatExportFeedbackPosition} from './useChatExportFeedbackPosition';\nimport {useKeyboardLayoutFit} from './useKeyboardLayoutFit';\n\nimport './ChatContainer.scss';\n\nconst b = block('chat-container');\nconst DEFAULT_MASCOT_CONFIG: MascotConfig = {};\n\ntype NormalizedChatContainerQa = ReturnType<typeof normalizeChatContainerQa>;\n\nfunction toSuggestionContext(\n id?: string,\n data?: Record<string, unknown>,\n): TSuggestionContext | undefined {\n if (!id && !data) {\n return undefined;\n }\n\n return {\n ...(id && {id}),\n ...(data && {data}),\n };\n}\n\nfunction mergePromptInputSuggestionsProps(\n fromProps: PromptInputProps['suggestionsProps'] | undefined,\n textsSuggestTitle: ReactNode | undefined,\n): PromptInputProps['suggestionsProps'] | undefined {\n const hasSuggestionsFromProps = Boolean(fromProps);\n const hasSuggestTitleFromTexts = textsSuggestTitle !== undefined;\n if (!hasSuggestionsFromProps && !hasSuggestTitleFromTexts) {\n return undefined;\n }\n return {\n ...fromProps,\n suggestTitle: textsSuggestTitle ?? fromProps?.suggestTitle,\n };\n}\n\nfunction buildFinalPromptInputHeaderProps(args: {\n headerProps: NonNullable<ChatContainerProps['promptInputProps']>['headerProps'];\n contextItems: ChatContainerProps['contextItems'];\n showContextIndicator: ChatContainerProps['showContextIndicator'];\n contextIndicatorProps: ChatContainerProps['contextIndicatorProps'];\n qa: string | undefined;\n}): NonNullable<ChatContainerProps['promptInputProps']>['headerProps'] {\n const {headerProps, contextItems, showContextIndicator, contextIndicatorProps, qa} = args;\n\n // topContent replaces the default header entirely, so context-related\n // props are not allowed (and would be ignored) alongside it\n if (headerProps?.topContent) {\n return {topContent: headerProps.topContent, qa};\n }\n\n return {\n contextItems,\n showContextIndicator: showContextIndicator ?? headerProps?.showContextIndicator,\n contextIndicatorProps: contextIndicatorProps ?? headerProps?.contextIndicatorProps,\n qa,\n };\n}\n\nfunction buildFinalPromptInputProps(args: {\n promptInputProps: ChatContainerProps['promptInputProps'];\n onSendMessage: ChatContainerProps['onSendMessage'];\n onCancel: ChatContainerProps['onCancel'];\n status: ChatContainerProps['status'];\n contextItems: ChatContainerProps['contextItems'];\n showContextIndicator: ChatContainerProps['showContextIndicator'];\n contextIndicatorProps: ChatContainerProps['contextIndicatorProps'];\n texts: ChatContainerTexts;\n promptInputKey: number;\n commandsResetKey: string | number;\n qaMap: NormalizedChatContainerQa;\n onValueChange?: (value: string) => void;\n}) {\n const {\n promptInputProps,\n onSendMessage,\n onCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n texts: textsArg,\n promptInputKey,\n commandsResetKey,\n qaMap,\n onValueChange,\n } = args;\n\n const texts = textsArg ?? {};\n\n const {\n autoFocusOnNewChat: _autoFocusOnNewChat,\n autoFocusOnChatSelect: _autoFocusOnChatSelect,\n ...restBodyProps\n } = promptInputProps?.bodyProps ?? {};\n\n const suggestionsProps = mergePromptInputSuggestionsProps(\n promptInputProps?.suggestionsProps,\n texts.promptSuggestTitle,\n );\n\n return {\n ...promptInputProps,\n commandsResetKey,\n onValueChange:\n onValueChange || promptInputProps?.onValueChange\n ? (value: string) => {\n onValueChange?.(value);\n promptInputProps?.onValueChange?.(value);\n }\n : undefined,\n qa: resolveChatContainerQa(qaMap, 'promptInput', 'prompt-input') ?? promptInputProps?.qa,\n onSend: onSendMessage,\n onCancel,\n status,\n suggestionsProps,\n headerProps: buildFinalPromptInputHeaderProps({\n headerProps: promptInputProps?.headerProps,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputHeader', 'prompt-input-header') ??\n promptInputProps?.headerProps?.qa,\n }),\n bodyProps: {\n ...restBodyProps,\n placeholder:\n texts.promptPlaceholder || restBodyProps?.placeholder || i18n('prompt-placeholder'),\n // The remount that clears the draft on a new or a freshly picked chat also puts the\n // cursor in the field. On a touch device that raises the keyboard over half the\n // screen, so a consumer that asked for no auto focus is taken at its word and keeps\n // the clearing without the cursor.\n autoFocus: restBodyProps?.autoFocus ?? promptInputKey > 0,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputBody', 'prompt-input-body') ??\n restBodyProps?.qa,\n },\n footerProps: {\n ...promptInputProps?.footerProps,\n submitButtonTooltipSend:\n texts?.submitSendTooltip ?? promptInputProps?.footerProps?.submitButtonTooltipSend,\n submitButtonTooltipCancel:\n texts?.submitCancelTooltip ??\n promptInputProps?.footerProps?.submitButtonTooltipCancel,\n submitButtonCancelableText:\n texts?.submitButtonCancelableText ??\n promptInputProps?.footerProps?.submitButtonCancelableText,\n qa:\n resolveChatContainerQa(qaMap, 'promptInputFooter', 'prompt-input-footer') ??\n promptInputProps?.footerProps?.qa,\n submitButtonQa:\n resolveChatContainerQa(qaMap, 'submitButton', 'submit-button') ??\n promptInputProps?.footerProps?.submitButtonQa,\n },\n };\n}\n\n/**\n * ChatContainer - fully assembled chat component, the main exportable component of the library.\n * Integrates Header, ChatContent, History and manages their state.\n *\n * @param props - component props\n * @returns React component\n */\nexport function ChatContainer(props: ChatContainerProps) {\n const {\n chats = [],\n messages = [],\n onSendMessage,\n onDeleteChat,\n onCancel,\n onRetry,\n status = 'ready',\n error = null,\n showActionsOnHover = false,\n contextItems = [],\n showContextIndicator,\n contextIndicatorProps,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n messageListConfig,\n showMascot = false,\n mascotConfig: customMascotConfig,\n headerProps = {},\n contentProps = {},\n emptyContainerProps = {},\n promptInputProps = {},\n disclaimerProps = {},\n historyProps = {},\n welcomeConfig,\n texts = {},\n hideTitleOnEmptyChat = false,\n isMobile: isMobileProp,\n adjustToKeyboard = true,\n floatingHeader = false,\n className,\n headerClassName,\n contentClassName,\n footerClassName,\n qa,\n } = props;\n\n const isMobileContext = useMobile();\n const isMobile = isMobileProp ?? isMobileContext;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const viewportProbeRef = useRef<HTMLDivElement>(null);\n const isKeyboardTracked = isMobile && adjustToKeyboard;\n // Keeps the footer (prompt input + disclaimer) above the on-screen keyboard on iOS Safari,\n // where the layout viewport stays full-height while the keyboard is open.\n const {isKeyboardOpen, maxHeight} = useKeyboardViewportFit(rootRef, isKeyboardTracked, {\n viewportProbeRef,\n });\n // Measured at all times, not only while the keyboard is open: otherwise the field grows by\n // its own row counter while the keyboard is away, and by the next time it comes back the\n // field is already taller than the space left, with the cap long gone.\n const {promptInputMaxHeight, isHeroFitting} = useKeyboardLayoutFit(\n rootRef,\n headerRef,\n footerRef,\n isKeyboardTracked,\n );\n\n const hookState = useChatContainer(props);\n const chatActivity = useChatActivity(props.chatActivity?.store, {\n chatId: hookState.activeChat?.id,\n isPanelVisible: props.chatActivity?.isPanelVisible ?? false,\n renderedResponseId: props.chatActivity?.renderedResponseId,\n });\n\n const chatExport = useChatExport({\n conversationKey: hookState.chatExportKey,\n chatId: props.activeChat?.id,\n messages,\n status,\n config: props.chatExport,\n });\n const exportFeedbackPosition = useChatExportFeedbackPosition(\n rootRef,\n Boolean(chatExport.notice),\n );\n const exportFeedback = chatExport.notice && (\n <Portal>\n <div className={b('export-overlay')} style={exportFeedbackPosition}>\n <div role=\"status\" className={b('export-feedback')}>\n <Alert\n theme={chatExport.notice.error ? 'danger' : 'success'}\n message={chatExport.notice.text}\n onClose={chatExport.dismissNotice}\n />\n </div>\n </div>\n </Portal>\n );\n\n const mascotConfig = customMascotConfig ?? (showMascot ? DEFAULT_MASCOT_CONFIG : undefined);\n const mascotState = useChatContainerMascot({\n config: mascotConfig,\n view: hookState.chatContentView === 'empty' ? 'hero' : 'chat',\n status,\n messagesCount: messages.length,\n activeChatId: hookState.activeChat?.id,\n promptInputKey: hookState.promptInputKey,\n });\n\n const promptApiRef = useRef<PromptInputHandle>(null);\n const mergedPromptApiRef = useForkRef(promptApiRef, promptInputProps?.apiRef);\n\n const wrappedOnSendMessage = useCallback(\n async (...args: Parameters<typeof onSendMessage>) => {\n mascotState.notifyActivity();\n return onSendMessage(...args);\n },\n [mascotState.notifyActivity, onSendMessage],\n );\n const wrappedOnCancel = useMemo(() => {\n if (!onCancel) {\n return undefined;\n }\n return async () => {\n await onCancel();\n mascotState.handleCancelResolved();\n };\n }, [mascotState.handleCancelResolved, onCancel]);\n const wrappedOnRetry = useMemo(() => {\n if (!onRetry) {\n return undefined;\n }\n return () => {\n mascotState.notifyActivity();\n onRetry();\n };\n }, [mascotState.notifyActivity, onRetry]);\n\n const resolvedMascotAssets = useMemo(\n () => resolveMascotAssets(mascotConfig?.defaultAssets, mascotConfig?.assets),\n [mascotConfig?.assets, mascotConfig?.defaultAssets],\n );\n const resolvedMascots = useMemo(\n () =>\n resolveMascotCollection(\n resolveMascotCollection(\n showMascot ? defaultGravityMascots : undefined,\n mascotConfig?.defaultMascots,\n ),\n mascotConfig?.mascots,\n ),\n [showMascot, mascotConfig?.defaultMascots, mascotConfig?.mascots],\n );\n const mascotView = hookState.chatContentView === 'empty' ? 'hero' : 'chat';\n const mascotNode = useMemo(() => {\n if (!mascotConfig) {\n return undefined;\n }\n if (mascotView === 'hero' && mascotConfig.showOnWelcome === false) {\n return undefined;\n }\n if (mascotView === 'chat' && mascotConfig.showInChat === false) {\n return undefined;\n }\n const node = mascotConfig.renderMascot\n ? mascotConfig.renderMascot({\n view: mascotView,\n state: mascotState.state,\n animationType: getMascotAnimationType(mascotState.state),\n assets: resolvedMascotAssets,\n })\n : getMascotNode(resolvedMascots, mascotView, mascotState.state);\n if (node === undefined || node === null) {\n return undefined;\n }\n return <div className={b('mascot', {view: mascotView})}>{node}</div>;\n }, [mascotConfig, mascotState.state, mascotView, resolvedMascotAssets, resolvedMascots]);\n\n const qaMap = useMemo(() => normalizeChatContainerQa(qa), [qa]);\n\n // Collect i18n texts with overrides\n const headerTitle = useMemo(\n () =>\n texts.headerTitle ||\n headerProps.title ||\n hookState.activeChat?.name ||\n i18n('header-default-title'),\n [texts.headerTitle, headerProps.title, hookState.activeChat?.name],\n );\n\n // Determine if chat is empty\n const isChatEmpty = hookState.chatContentView === 'empty';\n\n // Calculate showTitle based on hideTitleOnEmptyChat option\n const showTitle = useMemo(() => {\n // If explicit showTitle is provided in headerProps, use it\n if (headerProps.showTitle !== undefined) {\n return headerProps.showTitle;\n }\n // If hideTitleOnEmptyChat is enabled, show title only when chat has messages\n if (hideTitleOnEmptyChat && isChatEmpty) {\n return false;\n }\n return true;\n }, [hideTitleOnEmptyChat, isChatEmpty, headerProps.showTitle]);\n\n // Build props for Header\n const finalHeaderProps = useMemo(() => {\n const actionQa: Partial<Record<HeaderAction, string>> = {\n ...headerProps.actionQa,\n };\n const setHeaderActionQa = (\n action: HeaderAction,\n key: 'headerNewChat' | 'headerHistory' | 'headerFolding' | 'headerClose',\n suffix: string,\n ) => {\n const resolved = resolveChatContainerQa(qaMap, key, suffix);\n if (resolved !== undefined) {\n actionQa[action] = resolved;\n }\n };\n setHeaderActionQa(HeaderAction.NewChat, 'headerNewChat', 'header-action-newChat');\n setHeaderActionQa(HeaderAction.History, 'headerHistory', 'header-action-history');\n setHeaderActionQa(HeaderAction.Folding, 'headerFolding', 'header-action-folding');\n setHeaderActionQa(HeaderAction.Close, 'headerClose', 'header-action-close');\n\n const actionTooltipTexts: NonNullable<HeaderProps['actionTooltipTexts']> = {\n [HeaderAction.NewChat]:\n texts.headerNewChatTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.NewChat],\n [HeaderAction.History]:\n texts.headerHistoryTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.History],\n [HeaderAction.Close]:\n texts.headerCloseTooltip ?? headerProps.actionTooltipTexts?.[HeaderAction.Close],\n [HeaderAction.Folding]: {\n collapsed:\n texts.headerFoldingCollapsedTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.Folding]?.collapsed,\n opened:\n texts.headerFoldingOpenedTooltip ??\n headerProps.actionTooltipTexts?.[HeaderAction.Folding]?.opened,\n },\n };\n\n return {\n ...headerProps,\n historyActivity: props.chatActivity ? chatActivity : headerProps.historyActivity,\n title: headerTitle,\n showTitle,\n baseActions: hookState.baseActions,\n handleNewChat: hookState.handleNewChat,\n handleHistoryToggle: hookState.handleHistoryToggle,\n handleFolding: hookState.handleFolding,\n handleClose: hookState.handleClose,\n historyButtonRef: hookState.historyButtonRef,\n qa: resolveChatContainerQa(qaMap, 'header', 'header') ?? headerProps.qa,\n actionQa,\n actionTooltipTexts,\n menuButtonQa:\n resolveChatContainerQa(qaMap, 'headerMenuButton', 'header-menu-button') ??\n headerProps.menuButtonQa,\n menuButtonTooltip: texts.headerMenuTooltip ?? headerProps.menuButtonTooltip,\n menuItemQa: resolveHeaderMenuItemQa(\n qaMap,\n headerProps.menuItems,\n headerProps.menuItemQa,\n ),\n };\n }, [\n headerTitle,\n props.chatActivity,\n chatActivity,\n showTitle,\n hookState.baseActions,\n hookState.handleNewChat,\n hookState.handleHistoryToggle,\n hookState.handleFolding,\n hookState.handleClose,\n hookState.historyButtonRef,\n headerProps,\n qaMap,\n texts.headerNewChatTooltip,\n texts.headerHistoryTooltip,\n texts.headerCloseTooltip,\n texts.headerFoldingCollapsedTooltip,\n texts.headerFoldingOpenedTooltip,\n texts.headerMenuTooltip,\n ]);\n\n // Build props for EmptyContainer\n const finalEmptyContainerProps = useMemo(() => {\n const {showDefaultTitle = true, showDefaultDescription = true} = welcomeConfig || {};\n\n return {\n ...emptyContainerProps,\n qa:\n resolveChatContainerQa(qaMap, 'emptyState', 'empty-state') ??\n emptyContainerProps.qa,\n image: welcomeConfig?.image,\n title:\n texts.emptyStateTitle ??\n welcomeConfig?.title ??\n emptyContainerProps.title ??\n (showDefaultTitle ? i18n('empty-state-title') : undefined),\n description:\n texts.emptyStateDescription ??\n welcomeConfig?.description ??\n emptyContainerProps.description ??\n (showDefaultDescription ? i18n('empty-state-description') : undefined),\n suggestionTitle:\n texts.emptyStateSuggestionsTitle ??\n welcomeConfig?.suggestionTitle ??\n emptyContainerProps.suggestionTitle,\n suggestions: welcomeConfig?.suggestions,\n alignment: {\n ...emptyContainerProps.alignment,\n ...welcomeConfig?.alignment,\n ...(mascotView === 'hero' &&\n mascotNode &&\n emptyContainerProps.alignment?.hero === undefined &&\n welcomeConfig?.alignment?.hero === undefined\n ? {hero: 'center' as const}\n : {}),\n },\n heroContent:\n emptyContainerProps.heroContent ?? (mascotView === 'hero' ? mascotNode : undefined),\n layout: welcomeConfig?.layout ?? emptyContainerProps.layout,\n wrapText: welcomeConfig?.wrapText ?? emptyContainerProps.wrapText,\n showMore: welcomeConfig?.showMore,\n showMoreText:\n texts.emptyStateShowMoreText ??\n welcomeConfig?.showMoreText ??\n emptyContainerProps.showMoreText ??\n i18n('empty-state-show-more'),\n onSuggestionClick: async (\n content: string,\n suggestionId?: string,\n suggestionData?: Record<string, unknown>,\n ) => {\n const suggestion = toSuggestionContext(suggestionId, suggestionData);\n\n await promptApiRef.current?.submit({\n content,\n ...(suggestion && {suggestion}),\n });\n },\n };\n }, [\n welcomeConfig,\n emptyContainerProps,\n wrappedOnSendMessage,\n qaMap,\n texts.emptyStateTitle,\n texts.emptyStateDescription,\n texts.emptyStateSuggestionsTitle,\n texts.emptyStateShowMoreText,\n mascotNode,\n mascotView,\n ]);\n\n // Build props for MessageList\n const messageListProps = useMemo(\n () => ({\n ...messageListConfig,\n messages,\n status,\n errorMessage: texts.errorText\n ? {...(messageListConfig?.errorMessage ?? {}), text: texts.errorText}\n : messageListConfig?.errorMessage || (error ? {text: error.message} : undefined),\n onRetry: wrappedOnRetry,\n showActionsOnHover,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n qa:\n resolveChatContainerQa(qaMap, 'messageList', 'message-list') ??\n messageListConfig?.qa,\n actionPopupProps: {\n ...messageListConfig?.actionPopupProps,\n qa:\n resolveChatContainerQa(qaMap, 'actionPopup', 'action-popup') ??\n messageListConfig?.actionPopupProps?.qa,\n },\n footerContent:\n mascotView === 'chat' && mascotNode !== undefined && mascotNode !== null ? (\n <Fragment>\n {messageListConfig?.footerContent}\n {mascotNode}\n </Fragment>\n ) : (\n messageListConfig?.footerContent\n ),\n }),\n [\n messages,\n status,\n error,\n wrappedOnRetry,\n showActionsOnHover,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n messageListConfig,\n qaMap,\n texts.errorText,\n mascotNode,\n mascotView,\n ],\n );\n\n // Build props for PromptInput\n const finalPromptInputProps = useMemo(\n () =>\n buildFinalPromptInputProps({\n promptInputProps: {...promptInputProps, apiRef: mergedPromptApiRef},\n onSendMessage: wrappedOnSendMessage,\n onCancel: wrappedOnCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n texts,\n promptInputKey: hookState.promptInputKey,\n commandsResetKey: hookState.commandsResetKey,\n qaMap,\n onValueChange: mascotConfig ? mascotState.handleValueChange : undefined,\n }),\n [\n wrappedOnSendMessage,\n wrappedOnCancel,\n status,\n contextItems,\n showContextIndicator,\n contextIndicatorProps,\n promptInputProps,\n mergedPromptApiRef,\n hookState.promptInputKey,\n hookState.commandsResetKey,\n qaMap,\n texts.promptPlaceholder,\n texts.promptSuggestTitle,\n texts.submitSendTooltip,\n texts.submitCancelTooltip,\n texts.submitButtonCancelableText,\n mascotState.handleValueChange,\n mascotConfig,\n ],\n );\n\n // Build props for Disclaimer\n const finalDisclaimerProps = useMemo(() => {\n const disclaimerText =\n texts.disclaimerText ?? disclaimerProps.text ?? i18n('disclaimer-text');\n\n return {\n ...disclaimerProps,\n text: disclaimerText,\n qa: resolveChatContainerQa(qaMap, 'disclaimer', 'disclaimer') ?? disclaimerProps.qa,\n };\n }, [disclaimerProps, qaMap, texts.disclaimerText]);\n\n // Build props for ChatContent\n const finalContentProps = useMemo(\n () => ({\n ...contentProps,\n qa: resolveChatContainerQa(qaMap, 'content', 'content') ?? contentProps.qa,\n view: hookState.chatContentView as 'empty' | 'chat',\n emptyContainerProps: finalEmptyContainerProps,\n messageListProps,\n }),\n [\n hookState.chatContentView,\n finalEmptyContainerProps,\n messageListProps,\n contentProps,\n qaMap,\n ],\n );\n\n // Build props for History\n const finalHistoryProps = useMemo(\n () => ({\n ...historyProps,\n qa: resolveChatContainerQa(qaMap, 'history', 'history') ?? historyProps.qa,\n chats,\n activityStore: props.chatActivity?.store ?? historyProps.activityStore,\n selectedChat: hookState.activeChat,\n onSelectChat: hookState.handleSelectChat,\n onDeleteChat,\n open: hookState.isHistoryOpen,\n onOpenChange: (open: boolean) => {\n historyProps.onOpenChange?.(open);\n hookState.handleHistoryOpenChange(open);\n },\n anchorElement: hookState.historyButtonRef.current,\n emptyPlaceholder:\n texts.historyEmptyPlaceholder ??\n historyProps.emptyPlaceholder ??\n i18n('history-empty'),\n emptyFilteredPlaceholder:\n texts.historyEmptyFilteredPlaceholder ??\n historyProps.emptyFilteredPlaceholder ??\n i18n('history-empty-filtered'),\n searchPlaceholder: texts.historySearchPlaceholder ?? historyProps.searchPlaceholder,\n }),\n [\n chats,\n props.chatActivity?.store,\n hookState.activeChat,\n hookState.handleSelectChat,\n onDeleteChat,\n hookState.isHistoryOpen,\n hookState.handleHistoryOpenChange,\n hookState.historyButtonRef,\n historyProps,\n qaMap,\n texts.historyEmptyPlaceholder,\n texts.historyEmptyFilteredPlaceholder,\n texts.historySearchPlaceholder,\n ],\n );\n\n const showFooter = finalPromptInputProps || finalDisclaimerProps;\n\n const rootStyle = useMemo<CSSProperties | undefined>(() => {\n if (maxHeight === undefined && promptInputMaxHeight === undefined && isHeroFitting) {\n return undefined;\n }\n\n return {\n ...(maxHeight === undefined ? undefined : {maxHeight}),\n ...(promptInputMaxHeight === undefined\n ? undefined\n : {\n '--g-aikit-prompt-input-body-textarea-max-height': `${promptInputMaxHeight}px`,\n }),\n ...(isHeroFitting\n ? undefined\n : {'--g-aikit-empty-container-hero-visibility': 'hidden'}),\n } as CSSProperties;\n }, [maxHeight, promptInputMaxHeight, isHeroFitting]);\n\n return (\n <MobileProvider mobile={isMobile}>\n <div\n ref={rootRef}\n className={b(\n {\n mobile: isMobile,\n 'keyboard-open': isKeyboardOpen,\n 'floating-header': floatingHeader,\n },\n className,\n )}\n style={rootStyle}\n data-qa={resolveChatContainerRootQa(qaMap)}\n >\n {isKeyboardTracked && (\n <div className={b('viewport-probe')} ref={viewportProbeRef} aria-hidden />\n )}\n <div className={b('header', headerClassName)} ref={headerRef}>\n <Header\n {...finalHeaderProps}\n menuItems={[...(finalHeaderProps.menuItems ?? []), ...chatExport.menuItems]}\n />\n </div>\n <div className={b('content', {view: hookState.chatContentView}, contentClassName)}>\n <ChatContent {...finalContentProps} />\n </div>\n {showFooter && (\n <div\n className={b('footer', {view: hookState.chatContentView}, footerClassName)}\n ref={footerRef}\n >\n {finalPromptInputProps && (\n <PromptInput\n key={hookState.promptInputKey}\n {...finalPromptInputProps}\n />\n )}\n {finalDisclaimerProps && <Disclaimer {...finalDisclaimerProps} />}\n </div>\n )}\n {/* History is integrated via popup anchored to button in Header */}\n <History {...finalHistoryProps} />\n {!chatExport.dialogProps.open && exportFeedback}\n {props.chatExport && chatExport.dialogProps.open && (\n <ChatExportDialog {...chatExport.dialogProps} feedback={exportFeedback} />\n )}\n </div>\n </MobileProvider>\n );\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { MdxProps, MessageListProps } from "../../organisms/MessageList/index.js
|
|
|
3
3
|
import type { MermaidOptions } from "../../../markdown/types.js";
|
|
4
4
|
import type { ChatStatus, ChatType, MascotAssets, MascotCollection, MascotRenderContext, MascotState, TChatMessage, TSubmitData } from "../../../types/index.js";
|
|
5
5
|
import type { SuggestionsItem } from "../../../types/common.js";
|
|
6
|
+
import type { ChatActivityStore } from "../../../utils/chatActivity/index.js";
|
|
6
7
|
import type { ChatMarkdownOptions } from "../../../utils/chatMarkdown.js";
|
|
7
8
|
import type { ContextIndicatorProps } from "../../atoms/ContextIndicator/index.js";
|
|
8
9
|
import type { DisclaimerProps } from "../../atoms/Disclaimer/index.js";
|
|
@@ -178,6 +179,14 @@ export interface ChatExportConfig extends ChatMarkdownOptions {
|
|
|
178
179
|
* Props for ChatContainer component
|
|
179
180
|
*/
|
|
180
181
|
export interface ChatContainerProps {
|
|
182
|
+
/** Stable account-scoped activity source; accepts local and server-backed stores. */
|
|
183
|
+
chatActivity?: {
|
|
184
|
+
store: ChatActivityStore;
|
|
185
|
+
/** False while the host panel is closed or collapsed. */
|
|
186
|
+
isPanelVisible: boolean;
|
|
187
|
+
/** The completed response actually rendered for activeChat; omit while loading it. */
|
|
188
|
+
renderedResponseId?: string;
|
|
189
|
+
};
|
|
181
190
|
/** Opt-in Markdown export. Supply complete history in messages, including off-screen messages. */
|
|
182
191
|
chatExport?: ChatExportConfig;
|
|
183
192
|
/** Array of chats for history */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {MdxProps, MessageListProps} from 'src/components/organisms/MessageList';\n\nimport type {MermaidOptions} from '../../../markdown/types';\nimport type {\n ChatStatus,\n ChatType,\n MascotAssets,\n MascotCollection,\n MascotRenderContext,\n MascotState,\n TChatMessage,\n TSubmitData,\n} from '../../../types';\nimport type {SuggestionsItem} from '../../../types/common';\nimport type {ChatMarkdownOptions} from '../../../utils/chatMarkdown';\nimport type {ContextIndicatorProps} from '../../atoms/ContextIndicator';\nimport type {DisclaimerProps} from '../../atoms/Disclaimer';\nimport type {ContextItemConfig} from '../../molecules/PromptInputHeader';\nimport type {HeaderProps} from '../../organisms/Header';\nimport type {PromptInputProps} from '../../organisms/PromptInput';\nimport type {ChatContentProps} from '../../templates/ChatContent';\nimport type {AlignmentConfig, EmptyContainerProps} from '../../templates/EmptyContainer';\nimport type {HistoryProps} from '../../templates/History';\n\n/**\n * Welcome screen configuration\n */\nexport interface WelcomeConfig {\n /** Image or icon to display */\n image?: React.ReactNode;\n /** Title text or custom React element */\n title?: React.ReactNode;\n /** Description text or custom React element */\n description?: React.ReactNode;\n /** Suggestions section title - can be string or custom React element */\n suggestionTitle?: React.ReactNode;\n /** Array of suggestions (title will be used as message content) */\n suggestions?: SuggestionsItem[];\n /** Alignment configuration for image, title, and description */\n alignment?: AlignmentConfig;\n /** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */\n layout?: 'grid' | 'list';\n /** Enable text wrapping inside suggestion buttons instead of ellipsis */\n wrapText?: boolean;\n /** Show default title when neither title nor `texts.emptyStateTitle` / `emptyContainerProps.title` are provided */\n showDefaultTitle?: boolean;\n /** Show default description when neither description nor `texts.emptyStateDescription` / `emptyContainerProps.description` are provided */\n showDefaultDescription?: boolean;\n /** Show more suggestions callback */\n showMore?: () => void;\n /** Show more button text */\n showMoreText?: string;\n}\n\nexport interface MascotConfig<TAsset = string> {\n /** External state override, primarily for audio states or full consumer control. */\n stateOverride?: MascotState;\n assets?: MascotAssets<TAsset>;\n defaultAssets?: MascotAssets<TAsset>;\n /** Ready-to-render animated mascots grouped by welcome/chat surface and state. */\n mascots?: MascotCollection;\n /** Product-wide fallback mascots merged underneath `mascots`. */\n defaultMascots?: MascotCollection;\n /** Advanced renderer. Takes precedence over `mascots` when provided. */\n renderMascot?: (context: MascotRenderContext<TAsset>) => React.ReactNode;\n showOnWelcome?: boolean;\n showInChat?: boolean;\n sleepDelayMs?: number | null;\n onceDurations?: Partial<Record<'reveal' | 'done' | 'error' | 'stopped', number>>;\n onStateChange?: (state: MascotState) => void;\n}\n\n/**\n * MessageList configuration\n */\nexport type MessageListConfig = Omit<\n MessageListProps,\n | 'messages'\n | 'status'\n | 'onRetry'\n | 'showActionsOnHover'\n | 'transformOptions'\n | 'openMarkdownLinksInNewTab'\n | 'mermaidOptions'\n | 'mdxProps'\n>;\n\n/**\n * Unified visible strings for ChatContainer and its subtree.\n *\n * `texts.*` always wins. Below that, each area uses `welcomeConfig`, per-section `*Props` text fields,\n * then built-in defaults from `i18n()`.\n */\nexport interface ChatContainerTexts {\n /** Default header title when not using `headerProps.title` or active chat name */\n headerTitle?: string;\n /** Tooltip for the \"new chat\" header button */\n headerNewChatTooltip?: string;\n /** Tooltip for the \"history\" header button */\n headerHistoryTooltip?: string;\n /** Tooltip for the \"close\" header button */\n headerCloseTooltip?: string;\n /** Tooltip for the folding header button when collapsed (expand action) */\n headerFoldingCollapsedTooltip?: string;\n /** Tooltip for the folding header button when opened (collapse action) */\n headerFoldingOpenedTooltip?: string;\n /** Tooltip for the header menu button */\n headerMenuTooltip?: string;\n /** Empty state / welcome title */\n emptyStateTitle?: React.ReactNode;\n /** Empty state / welcome description */\n emptyStateDescription?: React.ReactNode;\n /** Title above suggestions on welcome screen */\n emptyStateSuggestionsTitle?: React.ReactNode;\n /** \"Show more\" button label on welcome screen */\n emptyStateShowMoreText?: string;\n /** Prompt textarea placeholder */\n promptPlaceholder?: string;\n /** Title above suggestions rendered inside PromptInput (`promptInputProps.suggestionsProps.suggestTitle`) */\n promptSuggestTitle?: React.ReactNode;\n /** Submit button tooltip (send / ready state) */\n submitSendTooltip?: string;\n /** Submit button tooltip (cancel / streaming state) */\n submitCancelTooltip?: string;\n /** Label rendered next to the submit button in cancelable state (`submitButtonCancelableText`) */\n submitButtonCancelableText?: string;\n /** Message list error alert main text */\n errorText?: string;\n /** History search/filter placeholder */\n historySearchPlaceholder?: string;\n /** History panel empty state when there are no chats */\n historyEmptyPlaceholder?: React.ReactNode;\n /** History panel empty state when search has no results */\n historyEmptyFilteredPlaceholder?: React.ReactNode;\n /** Disclaimer body text (must be a string; use `disclaimerProps.children` for custom nodes) */\n disclaimerText?: string;\n}\n\n/**\n * Unified test identifiers (`data-qa`) for ChatContainer and its subtree.\n *\n * - Pass a **string** for backward compatibility: only the root container gets `data-qa`.\n * - Pass **`{ prefix: 'x' }`** to opt in to `${prefix}-${suffix}` for every slot below (see README).\n * - Pass **explicit keys** to override individual elements; they win over `prefix` and nested `*Props.qa`.\n */\nexport interface ChatContainerQa {\n /** Applied to child slots when explicit keys are omitted; also used as root if `root` is omitted */\n prefix?: string;\n /** Root chat container */\n root?: string;\n /** Header root */\n header?: string;\n /** Overrides default `header-action-newChat` */\n headerNewChat?: string;\n /** Overrides default `header-action-history` */\n headerHistory?: string;\n /** Overrides default `header-action-folding` */\n headerFolding?: string;\n /** Overrides default `header-action-close` */\n headerClose?: string;\n /** Overrides default `header-menu-button` */\n headerMenuButton?: string;\n /** ChatContent root */\n content?: string;\n /** Empty state (EmptyContainer) */\n emptyState?: string;\n /** MessageList scroll area */\n messageList?: string;\n /** Action popup in MessageList */\n actionPopup?: string;\n /** PromptInput root */\n promptInput?: string;\n promptInputHeader?: string;\n promptInputBody?: string;\n promptInputFooter?: string;\n /** Submit button in prompt footer */\n submitButton?: string;\n /** Disclaimer text block */\n disclaimer?: string;\n /** History list (inside popup) */\n history?: string;\n}\n\n/** Outcome of an export operation for its originating conversation. */\nexport type ChatExportResult = {\n action: 'copy' | 'download';\n /** Undefined for an unsaved conversation. */\n chatId?: string;\n} & ({status: 'success'} | {status: 'error'; error: unknown});\n\nexport interface ChatExportConfig extends ChatMarkdownOptions {\n /** Disable export until the full conversation history is loaded. */\n loading?: boolean;\n filename?: string;\n /** Replace built-in feedback. Stale results after switching chats are not delivered. */\n onResult?: (result: ChatExportResult) => void;\n}\n\n/**\n * Props for ChatContainer component\n */\nexport interface ChatContainerProps {\n /** Opt-in Markdown export. Supply complete history in messages, including off-screen messages. */\n chatExport?: ChatExportConfig;\n // Chat data\n /** Array of chats for history */\n chats?: ChatType[];\n /** Currently active chat */\n activeChat?: ChatType | null;\n /** Array of messages in current chat */\n messages?: TChatMessage[];\n\n // Main callbacks\n /** Callback when user sends a message */\n onSendMessage: (data: TSubmitData) => Promise<void | false>;\n /** Callback when user selects a chat from history */\n onSelectChat?: (chat: ChatType) => void;\n /** Callback when user creates a new chat */\n onCreateChat?: () => void;\n /** Callback when user deletes a chat */\n onDeleteChat?: (chat: ChatType) => Promise<void>;\n /** Callback when user deletes all chats */\n onDeleteAllChats?: () => Promise<void>;\n /** Callback when user folds or unfolds the chat */\n onFold?: (value: 'collapsed' | 'opened') => void;\n /** Callback when user closes the chat */\n onClose?: () => void;\n /** Callback when user cancels streaming */\n onCancel?: () => Promise<void>;\n\n // Layout\n /**\n * Enables mobile mode for the chat and all inner components.\n * When omitted, falls back to the `useMobile()` value from the\n * `@gravity-ui/uikit` `MobileProvider` context.\n */\n isMobile?: boolean;\n /**\n * In mobile mode, shrinks the container to the visible part of the viewport while the\n * on-screen keyboard is open, so the prompt input and the disclaimer stay above it.\n * Set to `false` when the host application handles the keyboard itself.\n *\n * @default true\n */\n adjustToKeyboard?: boolean;\n /**\n * Renders the header above the content instead of stacking it on top: the message list and\n * the welcome screen scroll underneath. The header is taken out of the flow, so the content\n * has to be offset by its height manually — the offset depends on the layout. Set an explicit\n * height first: `--g-aikit-chat-container-header-height` is `auto` by default and\n * `--g-aikit-chat-container-mobile-header-height` is `60px` in mobile mode. Pair it with a\n * transparent `--g-aikit-chat-container-header-background` to let the content show through.\n *\n * @example\n * .my-chat {\n * --g-aikit-chat-container-header-height: 60px;\n * --g-aikit-chat-container-header-background: transparent;\n * }\n * .my-chat .g-aikit-chat-container__content {\n * padding-top: var(--g-aikit-chat-container-header-height);\n * }\n */\n floatingHeader?: boolean;\n\n // States\n /** Chat status: submitted, streaming, ready, error */\n status?: ChatStatus;\n /** Error state */\n error?: Error | null;\n /** Show message actions on hover */\n showActionsOnHover?: boolean;\n /** Callback to retry after error */\n onRetry?: () => void;\n\n // Context\n /** Array of context items to display in prompt input header */\n contextItems?: ContextItemConfig[];\n /** Show context indicator in prompt input header */\n showContextIndicator?: boolean;\n /** Props for the context indicator */\n contextIndicatorProps?: ContextIndicatorProps;\n /** Transform options for markdown rendering */\n transformOptions?: OptionsType;\n /** Should parse incomplete markdown (e.g., during streaming) */\n shouldParseIncompleteMarkdown?: boolean;\n /** Enables Mermaid diagrams with an application-provided lazy loader. */\n mermaidOptions?: MermaidOptions;\n /** Open all markdown links rendered by the default message renderers in a new tab */\n openMarkdownLinksInNewTab?: boolean;\n /**\n * Grouped MDX/markdown rendering props forwarded to the message list:\n * `mdxOptions`, `getMarkdownExtraProps` and `getMdxContext`.\n */\n mdxProps?: MdxProps;\n\n // Configuration\n /** MessageList configuration for actions and loader behavior */\n messageListConfig?: MessageListConfig;\n /** Enable the built-in Gravity mascot. Custom mascot configuration takes precedence. */\n showMascot?: boolean;\n /** Mascot renderer, assets and lifecycle configuration. Enables custom mascots independently of `showMascot`. */\n mascotConfig?: MascotConfig;\n\n // Component props overrides\n /** Props override for Header component */\n headerProps?: Partial<\n Omit<HeaderProps, 'handleNewChat' | 'handleHistoryToggle' | 'handleFolding' | 'handleClose'>\n >;\n /** Props override for ChatContent component */\n contentProps?: Partial<Omit<ChatContentProps, 'view' | 'messageListProps'>>;\n /** Props override for EmptyContainer (welcome screen) */\n emptyContainerProps?: Partial<EmptyContainerProps>;\n /** Props override for PromptInput component */\n promptInputProps?: Partial<Omit<PromptInputProps, 'onSend' | 'onCancel'>>;\n /** Props override for Disclaimer component */\n disclaimerProps?: Partial<DisclaimerProps>;\n /** Props override for History component */\n historyProps?: Partial<\n Omit<\n HistoryProps,\n 'chats' | 'selectedChat' | 'onSelectChat' | 'onDeleteChat' | 'anchorElement'\n >\n >;\n\n // Configuration\n /** Welcome screen configuration for empty state */\n welcomeConfig?: WelcomeConfig;\n /** Unified flat text overrides for ChatContainer subtree */\n texts?: ChatContainerTexts;\n /** Show chat history feature */\n showHistory?: boolean;\n /** Show new chat button */\n showNewChat?: boolean;\n /** Show folding button */\n showFolding?: boolean;\n /** Show close button */\n showClose?: boolean;\n /** Hide header title when chat is empty */\n hideTitleOnEmptyChat?: boolean;\n\n // Styling\n /** Additional CSS class */\n className?: string;\n /** Additional CSS class for header section */\n headerClassName?: string;\n /** Additional CSS class for content section */\n contentClassName?: string;\n /** Additional CSS class for footer section */\n footerClassName?: string;\n /**\n * QA/test identifiers. A string sets only the root `data-qa`. Use {@link ChatContainerQa} for a full map or `prefix`.\n */\n qa?: string | ChatContainerQa;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {MdxProps, MessageListProps} from 'src/components/organisms/MessageList';\n\nimport type {MermaidOptions} from '../../../markdown/types';\nimport type {\n ChatStatus,\n ChatType,\n MascotAssets,\n MascotCollection,\n MascotRenderContext,\n MascotState,\n TChatMessage,\n TSubmitData,\n} from '../../../types';\nimport type {SuggestionsItem} from '../../../types/common';\nimport type {ChatActivityStore} from '../../../utils/chatActivity';\nimport type {ChatMarkdownOptions} from '../../../utils/chatMarkdown';\nimport type {ContextIndicatorProps} from '../../atoms/ContextIndicator';\nimport type {DisclaimerProps} from '../../atoms/Disclaimer';\nimport type {ContextItemConfig} from '../../molecules/PromptInputHeader';\nimport type {HeaderProps} from '../../organisms/Header';\nimport type {PromptInputProps} from '../../organisms/PromptInput';\nimport type {ChatContentProps} from '../../templates/ChatContent';\nimport type {AlignmentConfig, EmptyContainerProps} from '../../templates/EmptyContainer';\nimport type {HistoryProps} from '../../templates/History';\n\n/**\n * Welcome screen configuration\n */\nexport interface WelcomeConfig {\n /** Image or icon to display */\n image?: React.ReactNode;\n /** Title text or custom React element */\n title?: React.ReactNode;\n /** Description text or custom React element */\n description?: React.ReactNode;\n /** Suggestions section title - can be string or custom React element */\n suggestionTitle?: React.ReactNode;\n /** Array of suggestions (title will be used as message content) */\n suggestions?: SuggestionsItem[];\n /** Alignment configuration for image, title, and description */\n alignment?: AlignmentConfig;\n /** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */\n layout?: 'grid' | 'list';\n /** Enable text wrapping inside suggestion buttons instead of ellipsis */\n wrapText?: boolean;\n /** Show default title when neither title nor `texts.emptyStateTitle` / `emptyContainerProps.title` are provided */\n showDefaultTitle?: boolean;\n /** Show default description when neither description nor `texts.emptyStateDescription` / `emptyContainerProps.description` are provided */\n showDefaultDescription?: boolean;\n /** Show more suggestions callback */\n showMore?: () => void;\n /** Show more button text */\n showMoreText?: string;\n}\n\nexport interface MascotConfig<TAsset = string> {\n /** External state override, primarily for audio states or full consumer control. */\n stateOverride?: MascotState;\n assets?: MascotAssets<TAsset>;\n defaultAssets?: MascotAssets<TAsset>;\n /** Ready-to-render animated mascots grouped by welcome/chat surface and state. */\n mascots?: MascotCollection;\n /** Product-wide fallback mascots merged underneath `mascots`. */\n defaultMascots?: MascotCollection;\n /** Advanced renderer. Takes precedence over `mascots` when provided. */\n renderMascot?: (context: MascotRenderContext<TAsset>) => React.ReactNode;\n showOnWelcome?: boolean;\n showInChat?: boolean;\n sleepDelayMs?: number | null;\n onceDurations?: Partial<Record<'reveal' | 'done' | 'error' | 'stopped', number>>;\n onStateChange?: (state: MascotState) => void;\n}\n\n/**\n * MessageList configuration\n */\nexport type MessageListConfig = Omit<\n MessageListProps,\n | 'messages'\n | 'status'\n | 'onRetry'\n | 'showActionsOnHover'\n | 'transformOptions'\n | 'openMarkdownLinksInNewTab'\n | 'mermaidOptions'\n | 'mdxProps'\n>;\n\n/**\n * Unified visible strings for ChatContainer and its subtree.\n *\n * `texts.*` always wins. Below that, each area uses `welcomeConfig`, per-section `*Props` text fields,\n * then built-in defaults from `i18n()`.\n */\nexport interface ChatContainerTexts {\n /** Default header title when not using `headerProps.title` or active chat name */\n headerTitle?: string;\n /** Tooltip for the \"new chat\" header button */\n headerNewChatTooltip?: string;\n /** Tooltip for the \"history\" header button */\n headerHistoryTooltip?: string;\n /** Tooltip for the \"close\" header button */\n headerCloseTooltip?: string;\n /** Tooltip for the folding header button when collapsed (expand action) */\n headerFoldingCollapsedTooltip?: string;\n /** Tooltip for the folding header button when opened (collapse action) */\n headerFoldingOpenedTooltip?: string;\n /** Tooltip for the header menu button */\n headerMenuTooltip?: string;\n /** Empty state / welcome title */\n emptyStateTitle?: React.ReactNode;\n /** Empty state / welcome description */\n emptyStateDescription?: React.ReactNode;\n /** Title above suggestions on welcome screen */\n emptyStateSuggestionsTitle?: React.ReactNode;\n /** \"Show more\" button label on welcome screen */\n emptyStateShowMoreText?: string;\n /** Prompt textarea placeholder */\n promptPlaceholder?: string;\n /** Title above suggestions rendered inside PromptInput (`promptInputProps.suggestionsProps.suggestTitle`) */\n promptSuggestTitle?: React.ReactNode;\n /** Submit button tooltip (send / ready state) */\n submitSendTooltip?: string;\n /** Submit button tooltip (cancel / streaming state) */\n submitCancelTooltip?: string;\n /** Label rendered next to the submit button in cancelable state (`submitButtonCancelableText`) */\n submitButtonCancelableText?: string;\n /** Message list error alert main text */\n errorText?: string;\n /** History search/filter placeholder */\n historySearchPlaceholder?: string;\n /** History panel empty state when there are no chats */\n historyEmptyPlaceholder?: React.ReactNode;\n /** History panel empty state when search has no results */\n historyEmptyFilteredPlaceholder?: React.ReactNode;\n /** Disclaimer body text (must be a string; use `disclaimerProps.children` for custom nodes) */\n disclaimerText?: string;\n}\n\n/**\n * Unified test identifiers (`data-qa`) for ChatContainer and its subtree.\n *\n * - Pass a **string** for backward compatibility: only the root container gets `data-qa`.\n * - Pass **`{ prefix: 'x' }`** to opt in to `${prefix}-${suffix}` for every slot below (see README).\n * - Pass **explicit keys** to override individual elements; they win over `prefix` and nested `*Props.qa`.\n */\nexport interface ChatContainerQa {\n /** Applied to child slots when explicit keys are omitted; also used as root if `root` is omitted */\n prefix?: string;\n /** Root chat container */\n root?: string;\n /** Header root */\n header?: string;\n /** Overrides default `header-action-newChat` */\n headerNewChat?: string;\n /** Overrides default `header-action-history` */\n headerHistory?: string;\n /** Overrides default `header-action-folding` */\n headerFolding?: string;\n /** Overrides default `header-action-close` */\n headerClose?: string;\n /** Overrides default `header-menu-button` */\n headerMenuButton?: string;\n /** ChatContent root */\n content?: string;\n /** Empty state (EmptyContainer) */\n emptyState?: string;\n /** MessageList scroll area */\n messageList?: string;\n /** Action popup in MessageList */\n actionPopup?: string;\n /** PromptInput root */\n promptInput?: string;\n promptInputHeader?: string;\n promptInputBody?: string;\n promptInputFooter?: string;\n /** Submit button in prompt footer */\n submitButton?: string;\n /** Disclaimer text block */\n disclaimer?: string;\n /** History list (inside popup) */\n history?: string;\n}\n\n/** Outcome of an export operation for its originating conversation. */\nexport type ChatExportResult = {\n action: 'copy' | 'download';\n /** Undefined for an unsaved conversation. */\n chatId?: string;\n} & ({status: 'success'} | {status: 'error'; error: unknown});\n\nexport interface ChatExportConfig extends ChatMarkdownOptions {\n /** Disable export until the full conversation history is loaded. */\n loading?: boolean;\n filename?: string;\n /** Replace built-in feedback. Stale results after switching chats are not delivered. */\n onResult?: (result: ChatExportResult) => void;\n}\n\n/**\n * Props for ChatContainer component\n */\nexport interface ChatContainerProps {\n /** Stable account-scoped activity source; accepts local and server-backed stores. */\n chatActivity?: {\n store: ChatActivityStore;\n /** False while the host panel is closed or collapsed. */\n isPanelVisible: boolean;\n /** The completed response actually rendered for activeChat; omit while loading it. */\n renderedResponseId?: string;\n };\n /** Opt-in Markdown export. Supply complete history in messages, including off-screen messages. */\n chatExport?: ChatExportConfig;\n // Chat data\n /** Array of chats for history */\n chats?: ChatType[];\n /** Currently active chat */\n activeChat?: ChatType | null;\n /** Array of messages in current chat */\n messages?: TChatMessage[];\n\n // Main callbacks\n /** Callback when user sends a message */\n onSendMessage: (data: TSubmitData) => Promise<void | false>;\n /** Callback when user selects a chat from history */\n onSelectChat?: (chat: ChatType) => void;\n /** Callback when user creates a new chat */\n onCreateChat?: () => void;\n /** Callback when user deletes a chat */\n onDeleteChat?: (chat: ChatType) => Promise<void>;\n /** Callback when user deletes all chats */\n onDeleteAllChats?: () => Promise<void>;\n /** Callback when user folds or unfolds the chat */\n onFold?: (value: 'collapsed' | 'opened') => void;\n /** Callback when user closes the chat */\n onClose?: () => void;\n /** Callback when user cancels streaming */\n onCancel?: () => Promise<void>;\n\n // Layout\n /**\n * Enables mobile mode for the chat and all inner components.\n * When omitted, falls back to the `useMobile()` value from the\n * `@gravity-ui/uikit` `MobileProvider` context.\n */\n isMobile?: boolean;\n /**\n * In mobile mode, shrinks the container to the visible part of the viewport while the\n * on-screen keyboard is open, so the prompt input and the disclaimer stay above it.\n * Set to `false` when the host application handles the keyboard itself.\n *\n * @default true\n */\n adjustToKeyboard?: boolean;\n /**\n * Renders the header above the content instead of stacking it on top: the message list and\n * the welcome screen scroll underneath. The header is taken out of the flow, so the content\n * has to be offset by its height manually — the offset depends on the layout. Set an explicit\n * height first: `--g-aikit-chat-container-header-height` is `auto` by default and\n * `--g-aikit-chat-container-mobile-header-height` is `60px` in mobile mode. Pair it with a\n * transparent `--g-aikit-chat-container-header-background` to let the content show through.\n *\n * @example\n * .my-chat {\n * --g-aikit-chat-container-header-height: 60px;\n * --g-aikit-chat-container-header-background: transparent;\n * }\n * .my-chat .g-aikit-chat-container__content {\n * padding-top: var(--g-aikit-chat-container-header-height);\n * }\n */\n floatingHeader?: boolean;\n\n // States\n /** Chat status: submitted, streaming, ready, error */\n status?: ChatStatus;\n /** Error state */\n error?: Error | null;\n /** Show message actions on hover */\n showActionsOnHover?: boolean;\n /** Callback to retry after error */\n onRetry?: () => void;\n\n // Context\n /** Array of context items to display in prompt input header */\n contextItems?: ContextItemConfig[];\n /** Show context indicator in prompt input header */\n showContextIndicator?: boolean;\n /** Props for the context indicator */\n contextIndicatorProps?: ContextIndicatorProps;\n /** Transform options for markdown rendering */\n transformOptions?: OptionsType;\n /** Should parse incomplete markdown (e.g., during streaming) */\n shouldParseIncompleteMarkdown?: boolean;\n /** Enables Mermaid diagrams with an application-provided lazy loader. */\n mermaidOptions?: MermaidOptions;\n /** Open all markdown links rendered by the default message renderers in a new tab */\n openMarkdownLinksInNewTab?: boolean;\n /**\n * Grouped MDX/markdown rendering props forwarded to the message list:\n * `mdxOptions`, `getMarkdownExtraProps` and `getMdxContext`.\n */\n mdxProps?: MdxProps;\n\n // Configuration\n /** MessageList configuration for actions and loader behavior */\n messageListConfig?: MessageListConfig;\n /** Enable the built-in Gravity mascot. Custom mascot configuration takes precedence. */\n showMascot?: boolean;\n /** Mascot renderer, assets and lifecycle configuration. Enables custom mascots independently of `showMascot`. */\n mascotConfig?: MascotConfig;\n\n // Component props overrides\n /** Props override for Header component */\n headerProps?: Partial<\n Omit<HeaderProps, 'handleNewChat' | 'handleHistoryToggle' | 'handleFolding' | 'handleClose'>\n >;\n /** Props override for ChatContent component */\n contentProps?: Partial<Omit<ChatContentProps, 'view' | 'messageListProps'>>;\n /** Props override for EmptyContainer (welcome screen) */\n emptyContainerProps?: Partial<EmptyContainerProps>;\n /** Props override for PromptInput component */\n promptInputProps?: Partial<Omit<PromptInputProps, 'onSend' | 'onCancel'>>;\n /** Props override for Disclaimer component */\n disclaimerProps?: Partial<DisclaimerProps>;\n /** Props override for History component */\n historyProps?: Partial<\n Omit<\n HistoryProps,\n 'chats' | 'selectedChat' | 'onSelectChat' | 'onDeleteChat' | 'anchorElement'\n >\n >;\n\n // Configuration\n /** Welcome screen configuration for empty state */\n welcomeConfig?: WelcomeConfig;\n /** Unified flat text overrides for ChatContainer subtree */\n texts?: ChatContainerTexts;\n /** Show chat history feature */\n showHistory?: boolean;\n /** Show new chat button */\n showNewChat?: boolean;\n /** Show folding button */\n showFolding?: boolean;\n /** Show close button */\n showClose?: boolean;\n /** Hide header title when chat is empty */\n hideTitleOnEmptyChat?: boolean;\n\n // Styling\n /** Additional CSS class */\n className?: string;\n /** Additional CSS class for header section */\n headerClassName?: string;\n /** Additional CSS class for content section */\n contentClassName?: string;\n /** Additional CSS class for footer section */\n footerClassName?: string;\n /**\n * QA/test identifiers. A string sets only the root `data-qa`. Use {@link ChatContainerQa} for a full map or `prefix`.\n */\n qa?: string | ChatContainerQa;\n}\n"]}
|
|
@@ -14,6 +14,7 @@ function useChatExport({ conversationKey, chatId, messages, status, config, }) {
|
|
|
14
14
|
const inFlight = (0, react_1.useRef)(false);
|
|
15
15
|
const [pending, setPending] = (0, react_1.useState)(false);
|
|
16
16
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
17
|
+
const [previews, setPreviews] = (0, react_1.useState)(new Map());
|
|
17
18
|
const [selected, setSelected] = (0, react_1.useState)(new Set());
|
|
18
19
|
const [notice, setNotice] = (0, react_1.useState)();
|
|
19
20
|
// Reset before paint and invalidate old operations, including an A -> B -> A switch.
|
|
@@ -35,21 +36,31 @@ function useChatExport({ conversationKey, chatId, messages, status, config, }) {
|
|
|
35
36
|
assistant: t('export-assistant'),
|
|
36
37
|
} }));
|
|
37
38
|
}, [config, t]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const unavailable = !enabled || (config === null || config === void 0 ? void 0 : config.loading) || (status !== 'ready' && status !== 'error');
|
|
40
|
+
// Inspect only built-in public fields here. Consumer serializers run inside export actions.
|
|
41
|
+
const entries = (0, react_1.useMemo)(() => unavailable
|
|
42
|
+
? []
|
|
43
|
+
: messages.flatMap((message, index) => {
|
|
44
|
+
const text = (0, chatMarkdown_1.getMessageMarkdown)(message);
|
|
45
|
+
const custom = message.role === 'assistant' &&
|
|
46
|
+
typeof message.content !== 'string' &&
|
|
47
|
+
(Array.isArray(message.content)
|
|
48
|
+
? message.content
|
|
49
|
+
: [message.content]).some((part) => !['text', 'thinking', 'tool'].includes(part.type));
|
|
50
|
+
return text || (custom && (config === null || config === void 0 ? void 0 : config.getContentMarkdown))
|
|
51
|
+
? [{ index, message, text }]
|
|
52
|
+
: [];
|
|
53
|
+
}), [unavailable, messages, config === null || config === void 0 ? void 0 : config.getContentMarkdown]);
|
|
54
|
+
const disabled = unavailable || pending || !entries.length;
|
|
47
55
|
const selectedEntries = entries.filter(({ index }) => selected.has(index));
|
|
48
|
-
//
|
|
49
|
-
|
|
56
|
+
// Public content and order identify the selection, not the array instance from a consumer.
|
|
57
|
+
const historyKey = unavailable
|
|
58
|
+
? ''
|
|
59
|
+
: JSON.stringify(entries.map(({ index, message, text }) => [index, message.id, message.role, text]));
|
|
60
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
50
61
|
setOpen(false);
|
|
51
62
|
setSelected((previous) => (previous.size ? new Set() : previous));
|
|
52
|
-
}, [
|
|
63
|
+
}, [historyKey]);
|
|
53
64
|
const run = async (action, selection = entries) => {
|
|
54
65
|
var _a;
|
|
55
66
|
if (!config || disabled || inFlight.current || !selection.length)
|
|
@@ -60,6 +71,8 @@ function useChatExport({ conversationKey, chatId, messages, status, config, }) {
|
|
|
60
71
|
let result;
|
|
61
72
|
try {
|
|
62
73
|
const markdown = (0, chatMarkdown_1.serializeChatMarkdown)(selection.map(({ message }) => message), options);
|
|
74
|
+
if (!markdown.trim())
|
|
75
|
+
throw new Error('No public content to export');
|
|
63
76
|
if (action === 'download') {
|
|
64
77
|
(0, chatMarkdown_1.downloadChatMarkdown)(markdown, config.filename);
|
|
65
78
|
}
|
|
@@ -116,6 +129,16 @@ function useChatExport({ conversationKey, chatId, messages, status, config, }) {
|
|
|
116
129
|
label: t('export-select'),
|
|
117
130
|
disabled,
|
|
118
131
|
onClick: () => {
|
|
132
|
+
setPreviews(new Map(entries.map(({ index, message, text }) => {
|
|
133
|
+
try {
|
|
134
|
+
return [index, (0, chatMarkdown_1.getMessageMarkdown)(message, options)];
|
|
135
|
+
}
|
|
136
|
+
catch (_a) {
|
|
137
|
+
// A broken custom preview must not prevent selecting other messages.
|
|
138
|
+
// Exporting this message still reports the serializer error via onResult.
|
|
139
|
+
return [index, text];
|
|
140
|
+
}
|
|
141
|
+
})));
|
|
119
142
|
setSelected(new Set(entries.map(({ index }) => index)));
|
|
120
143
|
setOpen(true);
|
|
121
144
|
},
|
|
@@ -125,11 +148,17 @@ function useChatExport({ conversationKey, chatId, messages, status, config, }) {
|
|
|
125
148
|
const dialogProps = {
|
|
126
149
|
open,
|
|
127
150
|
disabled: Boolean(disabled),
|
|
128
|
-
messages: entries.map(({ index, message, text }) =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
messages: (open ? entries : []).map(({ index, message, text }) => {
|
|
152
|
+
var _a;
|
|
153
|
+
const preview = (_a = previews.get(index)) !== null && _a !== void 0 ? _a : text;
|
|
154
|
+
return {
|
|
155
|
+
index,
|
|
156
|
+
text: preview
|
|
157
|
+
? `${options.roleLabels[message.role]}: ${preview}`
|
|
158
|
+
: options.roleLabels[message.role],
|
|
159
|
+
selected: selected.has(index),
|
|
160
|
+
};
|
|
161
|
+
}),
|
|
133
162
|
onSelectAll: (checked) => setSelected(new Set(checked ? entries.map(({ index }) => index) : [])),
|
|
134
163
|
onSelectionChange: (index, checked) => setSelected((previous) => {
|
|
135
164
|
const next = new Set(previous);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatExport.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/useChatExport.ts"],"names":[],"mappings":";;AAeA,sCAkKC;AAjLD,iCAA4E;AAE5E,iEAIqC;AACrC,qEAA8D;AAI9D,0CAA4B;AAG5B,0EAA0E;AAC1E,SAAgB,aAAa,CAAC,EAC1B,eAAe,EACf,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,GAOT;IACG,MAAM,EAAC,CAAC,EAAC,GAAG,WAAI,CAAC,cAAc,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CA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QAAQ,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;QAC7C,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;KAC5C,CAAC;AACN,CAAC","sourcesContent":["import {useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react';\n\nimport {\n downloadChatMarkdown,\n getMessageMarkdown,\n serializeChatMarkdown,\n} from '../../../utils/chatMarkdown';\nimport {copyToClipboard} from '../../../utils/clipboardUtils';\nimport type {HeaderMenuItem} from '../../organisms/Header';\n\nimport type {ChatExportDialogProps} from './ChatExportDialog';\nimport {i18n} from './i18n';\nimport type {ChatContainerProps, ChatExportResult} from './types';\n\n/** Own export operations and selection for one conversation at a time. */\nexport function useChatExport({\n conversationKey,\n chatId,\n messages,\n status,\n config,\n}: {\n conversationKey: string;\n chatId?: string;\n messages: NonNullable<ChatContainerProps['messages']>;\n status: ChatContainerProps['status'];\n config: ChatContainerProps['chatExport'];\n}) {\n const {t} = i18n.useTranslation();\n const enabled = Boolean(config);\n const scope = useMemo(() => ({}), [conversationKey, enabled]);\n const activeScope = useRef<object | null>(null);\n const inFlight = useRef(false);\n const [pending, setPending] = useState(false);\n const [open, setOpen] = useState(false);\n const [selected, setSelected] = useState<Set<number>>(new Set());\n const [notice, setNotice] = useState<{error: boolean; text: string}>();\n // Reset before paint and invalidate old operations, including an A -> B -> A switch.\n useLayoutEffect(() => {\n activeScope.current = scope;\n inFlight.current = false;\n setPending(false);\n setOpen(false);\n setSelected((previous) => (previous.size ? new Set() : previous));\n setNotice(undefined);\n return () => {\n activeScope.current = null;\n };\n }, [scope]);\n const options = useMemo(\n () => ({\n ...config,\n roleLabels: config?.roleLabels ?? {\n user: t('export-user'),\n assistant: t('export-assistant'),\n },\n }),\n [config, t],\n );\n const entries = useMemo(\n () =>\n (enabled ? messages : []).flatMap((message, index) => {\n const text = getMessageMarkdown(message, options);\n return text ? [{index, message, text}] : [];\n }),\n [enabled, messages, options],\n );\n const disabled =\n !enabled ||\n pending ||\n config?.loading ||\n (status !== 'ready' && status !== 'error') ||\n !entries.length;\n const selectedEntries = entries.filter(({index}) => selected.has(index));\n // Close selection when the history changes, rather than apply indices to different messages.\n useEffect(() => {\n setOpen(false);\n setSelected((previous) => (previous.size ? new Set() : previous));\n }, [messages]);\n\n const run = async (action: 'copy' | 'download', selection = entries) => {\n if (!config || disabled || inFlight.current || !selection.length) return;\n inFlight.current = true;\n setPending(true);\n setNotice(undefined);\n let result: ChatExportResult;\n try {\n const markdown = serializeChatMarkdown(\n selection.map(({message}) => message),\n options,\n );\n if (action === 'download') {\n downloadChatMarkdown(markdown, config.filename);\n } else if (!copyToClipboard(markdown)) {\n // Prefer the shared synchronous copy path while the user gesture is active.\n // The async API can be restricted in Safari and embedded previews.\n if (!navigator.clipboard?.writeText) {\n throw new Error('Clipboard copy failed');\n }\n await navigator.clipboard.writeText(markdown);\n }\n result = {action, status: 'success', chatId};\n } catch (error) {\n result = {action, status: 'error', chatId, error};\n } finally {\n if (activeScope.current === scope) {\n inFlight.current = false;\n setPending(false);\n }\n }\n if (activeScope.current !== scope) return;\n // Notify outside the operation catch: a consumer error is not an export failure.\n if (config.onResult) {\n config.onResult(result);\n } else {\n setNotice({\n error: result.status === 'error',\n text:\n result.status === 'success'\n ? t(action === 'copy' ? 'export-copied' : 'export-downloaded')\n : t(action === 'copy' ? 'export-copy-error' : 'export-download-error'),\n });\n }\n };\n\n const menuItems: HeaderMenuItem[] = enabled\n ? [\n {\n id: 'chat-export-copy',\n label: t('export-copy'),\n disabled,\n onClick: () => run('copy'),\n },\n {\n id: 'chat-export-download',\n label: t('export-download'),\n disabled,\n onClick: () => run('download'),\n },\n {\n id: 'chat-export-select',\n label: t('export-select'),\n disabled,\n onClick: () => {\n setSelected(new Set(entries.map(({index}) => index)));\n setOpen(true);\n },\n },\n ]\n : [];\n const dialogProps: ChatExportDialogProps = {\n open,\n disabled: Boolean(disabled),\n messages: entries.map(({index, message, text}) => ({\n index,\n text: `${options.roleLabels[message.role]}: ${text}`,\n selected: selected.has(index),\n })),\n onSelectAll: (checked) =>\n setSelected(new Set(checked ? entries.map(({index}) => index) : [])),\n onSelectionChange: (index, checked) =>\n setSelected((previous) => {\n const next = new Set(previous);\n if (checked) next.add(index);\n else next.delete(index);\n return next;\n }),\n onClose: () => setOpen(false),\n onCopy: () => run('copy', selectedEntries),\n onDownload: () => run('download', selectedEntries),\n };\n return {\n menuItems,\n dialogProps,\n notice: config?.onResult ? undefined : notice,\n dismissNotice: () => setNotice(undefined),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useChatExport.js","sourceRoot":"../../../../../src","sources":["components/pages/ChatContainer/useChatExport.ts"],"names":[],"mappings":";;AAeA,sCAmMC;AAlND,iCAAiE;AAEjE,iEAIqC;AACrC,qEAA8D;AAI9D,0CAA4B;AAG5B,0EAA0E;AAC1E,SAAgB,aAAa,CAAC,EAC1B,eAAe,EACf,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,GAOT;IACG,MAAM,EAAC,CAAC,EAAC,GAAG,WAAI,CAAC,cAAc,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EA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GAAG,CAAC,UAAU,EAAE,eAAe,CAAC;KACrD,CAAC;IACF,OAAO;QACH,SAAS;QACT,WAAW;QACX,MAAM,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;QAC7C,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;KAC5C,CAAC;AACN,CAAC","sourcesContent":["import {useLayoutEffect, useMemo, useRef, useState} from 'react';\n\nimport {\n downloadChatMarkdown,\n getMessageMarkdown,\n serializeChatMarkdown,\n} from '../../../utils/chatMarkdown';\nimport {copyToClipboard} from '../../../utils/clipboardUtils';\nimport type {HeaderMenuItem} from '../../organisms/Header';\n\nimport type {ChatExportDialogProps} from './ChatExportDialog';\nimport {i18n} from './i18n';\nimport type {ChatContainerProps, ChatExportResult} from './types';\n\n/** Own export operations and selection for one conversation at a time. */\nexport function useChatExport({\n conversationKey,\n chatId,\n messages,\n status,\n config,\n}: {\n conversationKey: string;\n chatId?: string;\n messages: NonNullable<ChatContainerProps['messages']>;\n status: ChatContainerProps['status'];\n config: ChatContainerProps['chatExport'];\n}) {\n const {t} = i18n.useTranslation();\n const enabled = Boolean(config);\n const scope = useMemo(() => ({}), [conversationKey, enabled]);\n const activeScope = useRef<object | null>(null);\n const inFlight = useRef(false);\n const [pending, setPending] = useState(false);\n const [open, setOpen] = useState(false);\n const [previews, setPreviews] = useState<Map<number, string>>(new Map());\n const [selected, setSelected] = useState<Set<number>>(new Set());\n const [notice, setNotice] = useState<{error: boolean; text: string}>();\n // Reset before paint and invalidate old operations, including an A -> B -> A switch.\n useLayoutEffect(() => {\n activeScope.current = scope;\n inFlight.current = false;\n setPending(false);\n setOpen(false);\n setSelected((previous) => (previous.size ? new Set() : previous));\n setNotice(undefined);\n return () => {\n activeScope.current = null;\n };\n }, [scope]);\n const options = useMemo(\n () => ({\n ...config,\n roleLabels: config?.roleLabels ?? {\n user: t('export-user'),\n assistant: t('export-assistant'),\n },\n }),\n [config, t],\n );\n const unavailable = !enabled || config?.loading || (status !== 'ready' && status !== 'error');\n // Inspect only built-in public fields here. Consumer serializers run inside export actions.\n const entries = useMemo(\n () =>\n unavailable\n ? []\n : messages.flatMap((message, index) => {\n const text = getMessageMarkdown(message);\n const custom =\n message.role === 'assistant' &&\n typeof message.content !== 'string' &&\n (Array.isArray(message.content)\n ? message.content\n : [message.content]\n ).some((part) => !['text', 'thinking', 'tool'].includes(part.type));\n return text || (custom && config?.getContentMarkdown)\n ? [{index, message, text}]\n : [];\n }),\n [unavailable, messages, config?.getContentMarkdown],\n );\n const disabled = unavailable || pending || !entries.length;\n const selectedEntries = entries.filter(({index}) => selected.has(index));\n // Public content and order identify the selection, not the array instance from a consumer.\n const historyKey = unavailable\n ? ''\n : JSON.stringify(\n entries.map(({index, message, text}) => [index, message.id, message.role, text]),\n );\n useLayoutEffect(() => {\n setOpen(false);\n setSelected((previous) => (previous.size ? new Set() : previous));\n }, [historyKey]);\n\n const run = async (action: 'copy' | 'download', selection = entries) => {\n if (!config || disabled || inFlight.current || !selection.length) return;\n inFlight.current = true;\n setPending(true);\n setNotice(undefined);\n let result: ChatExportResult;\n try {\n const markdown = serializeChatMarkdown(\n selection.map(({message}) => message),\n options,\n );\n if (!markdown.trim()) throw new Error('No public content to export');\n if (action === 'download') {\n downloadChatMarkdown(markdown, config.filename);\n } else if (!copyToClipboard(markdown)) {\n // Prefer the shared synchronous copy path while the user gesture is active.\n // The async API can be restricted in Safari and embedded previews.\n if (!navigator.clipboard?.writeText) {\n throw new Error('Clipboard copy failed');\n }\n await navigator.clipboard.writeText(markdown);\n }\n result = {action, status: 'success', chatId};\n } catch (error) {\n result = {action, status: 'error', chatId, error};\n } finally {\n if (activeScope.current === scope) {\n inFlight.current = false;\n setPending(false);\n }\n }\n if (activeScope.current !== scope) return;\n // Notify outside the operation catch: a consumer error is not an export failure.\n if (config.onResult) {\n config.onResult(result);\n } else {\n setNotice({\n error: result.status === 'error',\n text:\n result.status === 'success'\n ? t(action === 'copy' ? 'export-copied' : 'export-downloaded')\n : t(action === 'copy' ? 'export-copy-error' : 'export-download-error'),\n });\n }\n };\n\n const menuItems: HeaderMenuItem[] = enabled\n ? [\n {\n id: 'chat-export-copy',\n label: t('export-copy'),\n disabled,\n onClick: () => run('copy'),\n },\n {\n id: 'chat-export-download',\n label: t('export-download'),\n disabled,\n onClick: () => run('download'),\n },\n {\n id: 'chat-export-select',\n label: t('export-select'),\n disabled,\n onClick: () => {\n setPreviews(\n new Map(\n entries.map(({index, message, text}) => {\n try {\n return [index, getMessageMarkdown(message, options)];\n } catch {\n // A broken custom preview must not prevent selecting other messages.\n // Exporting this message still reports the serializer error via onResult.\n return [index, text];\n }\n }),\n ),\n );\n setSelected(new Set(entries.map(({index}) => index)));\n setOpen(true);\n },\n },\n ]\n : [];\n const dialogProps: ChatExportDialogProps = {\n open,\n disabled: Boolean(disabled),\n messages: (open ? entries : []).map(({index, message, text}) => {\n const preview = previews.get(index) ?? text;\n return {\n index,\n text: preview\n ? `${options.roleLabels[message.role]}: ${preview}`\n : options.roleLabels[message.role],\n selected: selected.has(index),\n };\n }),\n onSelectAll: (checked) =>\n setSelected(new Set(checked ? entries.map(({index}) => index) : [])),\n onSelectionChange: (index, checked) =>\n setSelected((previous) => {\n const next = new Set(previous);\n if (checked) next.add(index);\n else next.delete(index);\n return next;\n }),\n onClose: () => setOpen(false),\n onCopy: () => run('copy', selectedEntries),\n onDownload: () => run('download', selectedEntries),\n };\n return {\n menuItems,\n dialogProps,\n notice: config?.onResult ? undefined : notice,\n dismissNotice: () => setNotice(undefined),\n };\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type CSSProperties, type RefObject } from 'react';
|
|
2
|
+
/** Keep portalled feedback anchored to the chat, including inside the selection dialog. */
|
|
3
|
+
export declare function useChatExportFeedbackPosition(ref: RefObject<HTMLElement>, visible: boolean): CSSProperties | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useChatExportFeedbackPosition = useChatExportFeedbackPosition;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/** Keep portalled feedback anchored to the chat, including inside the selection dialog. */
|
|
6
|
+
function useChatExportFeedbackPosition(ref, visible) {
|
|
7
|
+
const [position, setPosition] = (0, react_1.useState)();
|
|
8
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const element = ref.current;
|
|
11
|
+
if (!visible || !element)
|
|
12
|
+
return undefined;
|
|
13
|
+
const update = () => {
|
|
14
|
+
const { top, left, width, height } = element.getBoundingClientRect();
|
|
15
|
+
setPosition({ top, left, width, height });
|
|
16
|
+
};
|
|
17
|
+
update();
|
|
18
|
+
const observer = new ResizeObserver(update);
|
|
19
|
+
observer.observe(element);
|
|
20
|
+
window.addEventListener('resize', update);
|
|
21
|
+
window.addEventListener('scroll', update, true);
|
|
22
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.addEventListener('resize', update);
|
|
23
|
+
(_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.addEventListener('scroll', update);
|
|
24
|
+
return () => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
observer.disconnect();
|
|
27
|
+
window.removeEventListener('resize', update);
|
|
28
|
+
window.removeEventListener('scroll', update, true);
|
|
29
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.removeEventListener('resize', update);
|
|
30
|
+
(_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.removeEventListener('scroll', update);
|
|
31
|
+
};
|
|
32
|
+
}, [ref, visible]);
|
|
33
|
+
return position;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=useChatExportFeedbackPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatExportFeedbackPosition.js","sourceRoot":"../../../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AC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YACnD,MAAA,MAAM,CAAC,cAAc,0CAAE,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC7D,MAAA,MAAM,CAAC,cAAc,0CAAE,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACnB,OAAO,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import {type CSSProperties, type RefObject, useLayoutEffect, useState} from 'react';\n\n/** Keep portalled feedback anchored to the chat, including inside the selection dialog. */\nexport function useChatExportFeedbackPosition(ref: RefObject<HTMLElement>, visible: boolean) {\n const [position, setPosition] = useState<CSSProperties>();\n useLayoutEffect(() => {\n const element = ref.current;\n if (!visible || !element) return undefined;\n const update = () => {\n const {top, left, width, height} = element.getBoundingClientRect();\n setPosition({top, left, width, height});\n };\n update();\n const observer = new ResizeObserver(update);\n observer.observe(element);\n window.addEventListener('resize', update);\n window.addEventListener('scroll', update, true);\n window.visualViewport?.addEventListener('resize', update);\n window.visualViewport?.addEventListener('scroll', update);\n return () => {\n observer.disconnect();\n window.removeEventListener('resize', update);\n window.removeEventListener('scroll', update, true);\n window.visualViewport?.removeEventListener('resize', update);\n window.visualViewport?.removeEventListener('scroll', update);\n };\n }, [ref, visible]);\n return position;\n}\n"]}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputControlSize } from '@gravity-ui/uikit';
|
|
3
3
|
import { ChatType } from "../../../types/index.js";
|
|
4
|
+
import type { ChatActivity } from "../../../utils/chatActivity/index.js";
|
|
4
5
|
/**
|
|
5
6
|
* Props for ChatItem component
|
|
6
7
|
*/
|
|
7
8
|
export interface ChatItemProps {
|
|
8
9
|
chat: ChatType;
|
|
10
|
+
activity?: ChatActivity;
|
|
11
|
+
showActivity?: boolean;
|
|
9
12
|
showActions: boolean;
|
|
10
13
|
pinned?: boolean;
|
|
11
14
|
onPinnedChange?: (chatId: string, pinned: boolean) => void;
|
|
@@ -21,4 +24,4 @@ export interface ChatItemProps {
|
|
|
21
24
|
*
|
|
22
25
|
* @returns React element
|
|
23
26
|
*/
|
|
24
|
-
export declare function ChatItem({ chat, showActions, isActive, onDeleteClick, size, pinned, onPinnedChange, pinningDisabled, }: ChatItemProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function ChatItem({ chat, activity, showActivity, showActions, isActive, onDeleteClick, size, pinned, onPinnedChange, pinningDisabled, }: ChatItemProps): import("react/jsx-runtime").JSX.Element;
|