/** * 文本输入组件公共类型定义 * 供 PisellSingleLineText、PisellLongText、PisellPhone、PisellEmail、PisellUrl 等组件使用 */ export type { DisplayState, ValidationResult } from '../common'; /** * 文本输入状态 Hook 返回值 */ export interface TextInputState { /** * 当前值 */ value: string | undefined; /** * 是否已被触摸(交互过) */ isTouched: boolean; /** * 是否校验通过 */ isValid: boolean; /** * 错误信息数组 */ errors: string[]; /** * 值变更处理函数 */ handleChange: (value: string) => void; /** * 失焦处理函数 */ handleBlur: () => void; /** * 聚焦处理函数 */ handleFocus: () => void; } /** * 基础文本输入 Props(供校验和状态管理使用) */ export interface BaseTextInputProps { value?: string; defaultValue?: string; required?: boolean; minLength?: number; maxLength?: number; pattern?: string | RegExp; validator?: (value: string) => boolean | string; validateTrigger?: 'onChange' | 'onBlur' | 'both'; errorMessage?: string; onChange?: (value: string) => void; onBlur?: (value: string) => void; onFocus?: () => void; onValidate?: (isValid: boolean, errors: string[]) => void; }