import type { UnknownRecord } from 'type-fest'; import type { CSSProperties, Component, VNodeChild } from 'vue'; import type { TooltipProps } from '../tooltip'; import type { RecorderCore, RecorderCoreInstance, RecorderCoreOptions } from './recorder-core'; export type SenderSubmitType = 'enter' | 'shiftEnter'; export type SenderInsertPosition = 'start' | 'end' | 'cursor'; export type SenderSuffixPlacement = 'content' | 'footer'; export type SenderSemanticType = 'root' | 'prefix' | 'input' | 'suffix' | 'footer' | 'switch' | 'content'; export interface SenderComponents { input?: Component; } export type SenderAllowSpeech = boolean | RecorderCoreOptions | UnknownRecord; export interface SenderSkillClosableConfig { closeIcon?: VNodeChild; onClose?: (event: MouseEvent) => void; disabled?: boolean; } export interface SenderSkill { title?: VNodeChild; value: string; tooltip?: string | TooltipProps; closable?: boolean | SenderSkillClosableConfig; } export interface SenderSlotConfigBase { type: 'text' | 'input' | 'select' | 'tag' | 'custom' | 'content'; formatResult?: (value: unknown) => string; } export interface SenderTextSlotConfig extends SenderSlotConfigBase { type: 'text'; value?: string; editable?: boolean; placeholder?: string; key?: string; } export interface SenderInputSlotConfig extends SenderSlotConfigBase { type: 'input'; key: string; props?: { defaultValue?: string | number; placeholder?: string; }; } export interface SenderSelectSlotConfig extends SenderSlotConfigBase { type: 'select'; key: string; props?: { defaultValue?: string; options: string[]; placeholder?: string; }; } export interface SenderTagSlotConfig extends SenderSlotConfigBase { type: 'tag'; key: string; props?: { label: string | number; value?: string; }; } export interface SenderContentSlotConfig extends SenderSlotConfigBase { type: 'content'; key: string; props?: { defaultValue?: unknown; placeholder?: string; }; } export interface SenderCustomSlotState { disabled?: boolean; readonly?: boolean; } export type SenderCustomSlotRender = (value: unknown, onChange: (value: unknown) => void, state: SenderCustomSlotState, item: SenderCustomSlotConfig) => VNodeChild; export interface SenderCustomSlotConfig extends SenderSlotConfigBase { type: 'custom'; key: string; props?: { defaultValue?: unknown; [key: string]: unknown; }; customRender?: SenderCustomSlotRender; } export type SenderSlotConfig = SenderTextSlotConfig | SenderInputSlotConfig | SenderSelectSlotConfig | SenderTagSlotConfig | SenderContentSlotConfig | SenderCustomSlotConfig; export type SenderResolvedSlotConfig = SenderSlotConfig & { value?: unknown; }; export interface SenderValue { value: string; slotConfig: SenderResolvedSlotConfig[]; skill?: SenderSkill; } export interface SenderFocusOptions { preventScroll?: boolean; cursor?: 'start' | 'end' | 'all' | 'slot'; key?: string; } export interface SenderRef { readonly Recorder: RecorderCore; readonly recorder: RecorderCoreInstance | null; readonly recording: boolean; readonly inputElement: HTMLTextAreaElement | HTMLDivElement | null; readonly nativeElement: HTMLDivElement | null; focus: (options?: SenderFocusOptions) => void; blur: () => void; insert: (value: string | SenderSlotConfig[], position?: SenderInsertPosition, replaceCharacters?: string, preventScroll?: boolean) => void; clear: () => void; getValue: () => SenderValue; } export interface SenderActionContext { send: () => void; clear: () => void; cancel: () => void; speech: () => void; submitDisabled: boolean; clearDisabled: boolean; cancelDisabled: boolean; speechDisabled: boolean; recording: boolean; loading: boolean; } export interface SenderProps { modelValue?: string; defaultValue?: string; loading?: boolean; readonly?: boolean | string; submitType?: SenderSubmitType; disabled?: boolean; slotConfig?: readonly SenderSlotConfig[]; allowSpeech?: SenderAllowSpeech; autoSize?: boolean | { minRows?: number; maxRows?: number; }; skill?: SenderSkill; placeholder?: string; showActions?: boolean; suffixPlacement?: SenderSuffixPlacement; components?: SenderComponents; classNames?: Partial>; styles?: Partial>; onKeydown?: (event: KeyboardEvent) => void | false; onKeyup?: (event: KeyboardEvent) => void; } export interface SenderEmits { 'update:modelValue': [value: string]; 'change': [ value: string, event: Event | undefined, slotConfig: SenderResolvedSlotConfig[], skill: SenderSkill | undefined ]; 'submit': [value: string, slotConfig: SenderResolvedSlotConfig[], skill: SenderSkill | undefined]; 'cancel': []; 'paste': [event: ClipboardEvent]; 'pasteFile': [files: FileList]; 'focus': [event: FocusEvent]; 'blur': [event: FocusEvent]; 'speechEnd': [blob: Blob, duration: number, mime: string]; 'speechError': [message: string, isUserNotAllow: boolean]; } export type SenderHeaderSemanticType = 'header' | 'content'; export interface SenderHeaderProps { open?: boolean; forceRender?: boolean; title?: VNodeChild; closable?: boolean; classNames?: Partial>; styles?: Partial>; } export interface SenderSwitchProps { modelValue?: boolean; defaultValue?: boolean; disabled?: boolean; loading?: boolean; classNames?: Partial>; styles?: Partial>; }