import type { ActionObject, EventListenerAction, SchemaClassName, SchemaExpression } from 'jamis-core'; import type { FormOptionsSchema, IFormItemStore, IFormStore, OptionsControlProps, PlainSchema, SchemaApi, StaticControlSchema } from '../types'; export type InputTextRendererEvent = 'blur' | 'focus' | 'click' | 'change' | 'enter'; /** * Text 文本输入框。 */ export interface TextControlSchema extends FormOptionsSchema { type: 'input-text' | 'input-email' | 'input-url' | 'input-password' | 'native-date' | 'native-time' | 'native-number' /** 在editor里使用 */ | 'input-text-i18n'; addOn?: (ActionObject | PlainSchema | StaticControlSchema) & { position?: 'left' | 'right'; label?: string; icon?: string; className?: string; }; placeholder?: string; className?: SchemaClassName; /** * 是否去除首尾空白文本。 */ trimContents?: boolean; /** * 自动完成 API,当输入部分文字的时候,会将这些文字通过 ${term} 可以取到,发送给接口。 * 接口可以返回匹配到的选项,帮助用户输入。 */ autoComplete?: SchemaApi; /** * 边框模式,全边框,还是半边框,或者没边框。 */ borderMode?: 'full' | 'half' | 'none'; minLength?: number; /** * 限制文字个数 */ maxLength?: number; /** * 是否显示计数 */ showCounter?: boolean; /** * 前缀 */ prefix?: SchemaExpression; prefixClassName?: SchemaClassName; /** * 后缀 */ suffix?: SchemaExpression; suffixClassName?: SchemaClassName; /** * 自动转换值 */ transform?: { /** 用户输入的字符自动转小写 */ lowerCase?: boolean; /** 用户输入的字符自动转大写 */ upperCase?: boolean; }; /** control节点的CSS类名 */ inputControlClassName?: string; /** 原生input标签的CSS类名 */ nativeInputClassName?: string; spinnerClassName?: SchemaClassName; onEvent?: { [key in InputTextRendererEvent]?: EventListenerAction; }; /** * 通过数据域来改变值时是否发出`change`事件, 默认是`false` */ emitChangeByScope?: boolean; /** * 变更防抖配置, 延迟多久触发`change`事件 */ emitChangeDelay?: number | boolean; /** * 键盘快捷键, 如 enter */ hotKey?: SchemaExpression; /** * 表单项value改变事件监听 * @deprecated 请使用onEvent.change替代 */ onChange?: (curr: any, prev: any, itemStore: IFormItemStore, formStore: IFormStore) => any; /** * @deprecated 使用onEvent.focus替代 */ onFocus?: (e: any) => void; /** * @deprecated 使用onEvent.blur替代 */ onBlur?: (e: any) => void; } export interface InputTextProps extends OptionsControlProps, Omit { addOn?: ActionObject & { position?: 'left' | 'right'; label?: string; icon?: string; className?: string; }; creatable?: boolean; clearable: boolean; resetValue?: any; autoComplete?: any; allowInputText?: boolean; spinnerClassName: string; revealPasswordProp?: boolean; /** control节点的CSS类名 */ inputControlClassName?: string; /** 原生input标签的CSS类名 */ nativeInputClassName?: string; } export interface InputTextRef { focus: () => void; clearValue: () => void; }