/** * Типы для конфигурации виджета чата (V2) */ // Базовые типы export type Size = 'sm' | 'md' | 'lg' export type BorderRadius = '0' | 'sm' | 'md' | 'lg' export type BtnType = 'icon' | 'text' | 'both' export type LaunchView = 'closed' | 'compact' export type Loader = 'dots' | 'dots-pulse' | 'circle-pulse' | 'circle-pulse-1' export type BgType = 'plain' | 'bubble' | 'gradient' export type InputStyle = 'inside' | 'stacked' | 'elastic' export type ButtonStyle = 'filled' | 'outlined' | 'invisible' export type WarningStyle = 'gradient' | 'filled' | 'faded' export type BackgroundStyle = 'invisible' | 'filled' | 'gradient' export type DataAction = 'steps' | 'box' | 'compact' | 'outline' export type BorderStyleType = 'solid' | 'dashed' | 'dotted' export type GradientDirection = 'to-top' | 'to-bottom' | 'to-left' | 'to-right' | 'to-top-right' | 'to-top-left' | 'to-bottom-right' | 'to-bottom-left' export type Theme = 'light' | 'dark' | 'auto' // Схема конфигурации export interface ConfigSchema { version: string required: string[] } // Настройки виджета export interface WidgetSettings { bgChat: string gapMessageLine: number fontFamily: string borderRadius: number launchView: LaunchView letterSpacing: number logo: string fontWeight: number loader: Loader lineHeight: number globalRoundingRadius: boolean theme: Theme mode: 'collapsed' position: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'top' | 'bottom' | 'left' | 'right' size: { width: number height: number } offset: { x: number y: number } container: ContainerConfig } // Тексты виджета export interface WidgetTexts { welcomeMessage: string widgetTitle: string launchIssueTitle: string launchIssueText: string issueText: string reconnectText: string inputPlaceholder: string disableInputText: string disclaimer: string typingLoader: string sendButton: string } // Базовые типы для элементов export interface BorderStyle { borderColor: string borderWidth?: number } export interface BorderConfig { width: number color: string style: BorderStyleType } export interface ContainerConfig { innerBorder: BorderConfig outerBorder: BorderConfig gradient: string } export interface ColorItems { color?: string bgColor?: string } export interface UIElement { color: string bgColor?: string type?: BtnType bgType?: BgType } export interface Icon { showIcon?: boolean src?: string color?: string size?: number } export interface IconElement { icon: Icon } export interface UIChatElement { color?: string bgColor?: string borderRadius?: number, size?: Size, fontSize?: number, width?: number, height?: number, sidePadding?: number, margin?: number, verticalPadding?: number, verticalSpacing?: number, showType?: BtnType borderWidth?: number borderColor?: string bgType?: BgType | ButtonStyle icon?: Icon } export interface InputSendElement extends UIChatElement { inputStyle: InputStyle paddingVertical?: number paddingHorizontal?: number } // Типы для Active Snippet export interface ActiveSnippetParams { buttonType: BtnType buttonStyle: ButtonStyle size: Size } export interface ActiveSnippetElement { params: ActiveSnippetParams element: UIChatElement headerChip: UIChatElement propertyColor: string valueColor: string yesButton: UIChatElement noButton: UIChatElement } // Типы для предупреждений export interface WarningParams { showIcon: boolean icon: string } export interface WarningElement { warningStyle: WarningStyle content: UIChatElement resetButton?: UIChatElement } export interface LaunchWarningElement extends WarningElement { content: UIChatElement & { headlineColor?: string headlineTextSize: number subTextSize: number } } export interface WarningsSection { launchIssue: LaunchWarningElement connectionIssue: WarningElement reconnectIssue: WarningElement disableInputIssue: WarningElement } // Типы для лоадера export interface LoaderSection { typingLoader: UIChatElement completeStep: UIChatElement activeStep: UIChatElement } // Типы для секций export interface TopSection { params: { size: Size bgColor: string bgStyle: BackgroundStyle chipStyle: ButtonStyle buttonStyle: ButtonStyle paddingVertical: number paddingHorizontal: number border: { width: number color: string } sideMargin: number borderRadius: number | string } chipWidgetTitle: UIChatElement buttons: UIChatElement } export interface InsideSection { params: { size: Size sidePadding: number verticalPadding: number } dataAction: { type: DataAction headerFillColor: string headerText: string bodyFillColor: string activeStepColor: string pastStepColor: string strokeColor: string strokeWidth: number } messageUser: UIChatElement messageBot: UIChatElement activeSnippet: ActiveSnippetElement welcomeMessage: UIChatElement } export interface BottomSection { params: { size: Size disclaimerShow: boolean } disclaimer: UIChatElement inputSend: InputSendElement btnSend: UIChatElement btnVoice: UIChatElement } export interface ColapsedSection extends UIChatElement {} export interface WidgetSections { colapsed: ColapsedSection & { logo: string icon: { showIcon: boolean size: number } } warnings: WarningsSection loader: LoaderSection top: TopSection inside: InsideSection bottom: BottomSection } // Основной тип конфигурации export interface WidgetConfig { schema: ConfigSchema settings: WidgetSettings texts: WidgetTexts sections: WidgetSections } // Типы для частичного обновления конфигурации export type PartialWidgetConfig = Partial export type PartialWidgetSettings = Partial export type PartialWidgetTexts = Partial export type PartialWidgetSections = Partial // Утилитарные типы export type ConfigKey = keyof WidgetConfig export type SettingsKey = keyof WidgetSettings export type TextsKey = keyof WidgetTexts export type SectionsKey = keyof WidgetSections // Типы для валидации export interface ConfigValidationResult { isValid: boolean errors: string[] } // Утилитарный тип для глубоких частичных объектов export type DeepPartial = { [P in keyof T]?: T[P] extends object ? DeepPartial : T[P] }