UNPKG

starchild-widget

Version:

Starchild Widget

191 lines 5.71 kB
import { ChangeEventHandler, CSSProperties, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react'; import { Position, BaseConfig, VoidCallback, PositionCallback, ErrorCallback, DockEdgeCallback, ChatModalDetachFromEdgeCallback } from '../common'; import { Theme, ThemeMode, ThemeConfig } from '../theme'; import { WidgetConfig } from '../widget'; import { Placement } from '@popperjs/core'; export interface DraggableButtonProps extends BaseConfig { position: Position; onPositionChange: PositionCallback; theme: Theme; onClick?: VoidCallback; children: React.ReactNode; 'aria-label'?: string; 'aria-describedby'?: string; role?: string; tabIndex?: number; } export interface ShadowRootProps { children: React.ReactNode; mode?: 'open' | 'closed'; globalCSS?: string; } export interface WidgetState { mounted: boolean; position: Position | null; theme: string; locale: string; disabled: boolean; error: Error | null; } export interface WidgetEvents { onPositionChange?: PositionCallback; onError?: ErrorCallback; onReady?: VoidCallback; onThemeChange?: (theme: string) => void; onLocaleChange?: (locale: string) => void; } export interface ComponentLifecycle { onMount?: VoidCallback; onUnmount?: VoidCallback; onUpdate?: (prevProps: any, prevState: any) => void; } export declare enum RenderMode { NORMAL = "normal", SHADOW_DOM = "shadow", PORTAL = "portal" } export interface ComponentStateManager<T = any> { state: T; setState: (updater: Partial<T> | ((prev: T) => T)) => void; getState: () => T; reset: () => void; } export interface AiWidgetProps extends Partial<WidgetConfig> { onError?: (error: Error) => void; onSearchOpen?: VoidCallback; onSearchClose?: VoidCallback; onChatModalOpen?: VoidCallback; onChatModalClose?: VoidCallback; onChatModalDockToEdge?: DockEdgeCallback; onChatModalDetachFromEdge?: ChatModalDetachFromEdgeCallback; chatModalContainer?: string; chatModalContainerElement?: HTMLElement; } interface BaseComponentProps extends BaseConfig { position?: Position; onPositionChange: PositionCallback; 'aria-label'?: string; 'aria-describedby'?: string; role?: string; tabIndex?: number; } export interface ChatProps extends BaseComponentProps { onClick?: VoidCallback; onChatModalOpen?: VoidCallback; onChatModalClose?: VoidCallback; onChatModalDockToEdge?: DockEdgeCallback; onChatModalDetachFromEdge?: ChatModalDetachFromEdgeCallback; containerId?: string; containerElement?: HTMLElement; } export interface SearchProps extends Omit<BaseComponentProps, 'position' | 'onPositionChange'> { onOpen?: VoidCallback; onClose?: VoidCallback; } export interface ThemeProviderProps { children: React.ReactNode; themeMode?: ThemeMode; customTheme?: ThemeConfig; className?: string; } export interface WidgetBridgeProps { widget: any; children: React.ReactNode; } /** * 输入框类型枚举 */ export declare enum InputType { SEARCH = "SEARCH",// 搜索输入 TEXT = "TEXT" } /** * 输入框组件属性接口 */ export interface PorpsType { type?: string; inputType?: InputType; inputStyle?: CSSProperties; placeholder?: string; rootStyle?: CSSProperties; inputClass?: string; disabled?: boolean; showError?: boolean; autoFocus?: boolean; inputValue?: string | number; inputMode?: 'text' | 'search' | 'email' | 'tel' | 'url' | 'none' | 'numeric' | 'decimal'; clearError?: () => void; onKeyUp?: KeyboardEventHandler<HTMLInputElement>; onBlur?: FocusEventHandler<HTMLInputElement>; onChange?: ChangeEventHandler<HTMLInputElement>; onFocus?: FocusEventHandler<HTMLInputElement>; onResetValue?: () => void; } /** * Portal组件属性接口 */ export interface PortalProps { children: ReactNode; rootEl?: HTMLElement | null | undefined; } export declare enum MoveType { LINE = "line", BG = "bg" } /** * Tooltip 触发方式枚举 */ export declare enum TriggerMethod { CLICK = 0,// 点击触发 HOVER = 1 } /** * Popover组件属性接口 */ export interface PopoverProps { content: ReactNode; show: boolean; children: ReactNode; placement?: Placement; offsetTop?: number; offsetLeft?: number; widthAuto?: boolean; begainToHide?: boolean; rootClass?: string; showArrow?: boolean; popoverContainerStyle?: CSSProperties; onClick?: MouseEventHandler<HTMLElement>; onMouseEnter?: MouseEventHandler<HTMLElement>; onMouseLeave?: MouseEventHandler<HTMLElement>; onClickOutside?: () => void; arrowStyle?: CSSProperties; } /** * Tooltip内容组件属性接口 */ export interface TooltipContentProps extends Omit<PopoverProps, 'content'> { contentStyle?: CSSProperties; content: ReactNode; emptyContent?: boolean; widthAuto?: boolean; canOperator?: boolean; onOpen?: (param?: any) => void; wrap?: boolean; onClick?: React.MouseEventHandler<HTMLElement>; childClick?: React.MouseEventHandler<HTMLElement>; onMouseEnter?: React.MouseEventHandler<HTMLElement>; onMouseLeave?: React.MouseEventHandler<HTMLElement>; outShow?: boolean; useOutShow?: boolean; ignoreTooltipConfig?: boolean; stopPropagation?: boolean; begainToHide?: boolean; showTooltipWrapper?: boolean; contentClass?: string; disabledDisappearAni?: boolean; outSetShow?: (param?: any) => void; disableHover?: boolean; triggerMethod?: TriggerMethod; } export {}; //# sourceMappingURL=index.d.ts.map