import { InputHTMLAttributes, ReactNode, ClipboardEvent } from 'react';
/**
* @title Input Props
*/
export interface InputProps extends Omit, 'onChange' | 'maxLength'> {
/**
* @zh 允许清空输入框
* @en Whether allow clear value
*/
allowClear?: boolean;
/**
* @zh 是否禁用
* @en Whether the input is disabled
*/
disabled?: boolean;
/**
* @zh 输入框状态
* @en Input box status
*/
status?: 'error' | 'warning';
/**
* @zh 是否只读
* @en Whether the input is readOnly
*/
readOnly?: boolean;
/**
* @zh 默认值
* @en The initial input content
*/
defaultValue?: string;
/**
* @zh 输入框提示文字
* @en Input box prompt text
*/
placeholder?: string;
/**
/**
* @zh 输入时的回调
* @en Callback when user input
*/
onChange?: (value: string, e: any) => void;
/**
* @zh 点击清除按钮的回调
* @en Callback when click clear button
*/
onClear?: (e: any) => void;
/**
* 粘贴事件
*/
onPaste?: (e: ClipboardEvent) => void;
/**
* @zh 按下回车键的回调
* @en Callback when press enter key
*/
onPressEnter?: (value: any, e: any) => void;
/**
* @zh 指定 normalize 执行的时机
* @en Specify the timing of normalize execution
* @defaultValue ['onBlur']
*/
normalizeTrigger?: ('onBlur' | 'onPressEnter')[];
/**
* @zh 在指定时机对用户输入的值进行格式化处理。前后值不一致时,会触发 onChange
* @en Format the value entered by the user at the specified time, and when the previous and subsequent values are inconsistent, onChange will be triggered
*/
normalize?: (value: string) => string;
/**
* @zh 输入框的值,受控模式
* @en The input content value
*/
value?: string;
/**
* @zh 输入框最大输入的长度;设置 `errorOnly`为 `true` 后,超过 `maxLength` 会展示 `error` 状态,并不限制用户输入。
* @en The max content length;After setting `errorOnly` to `true`, if `maxLength` is exceeded, the `error` status will be displayed, and user input will not be restricted.
*/
maxLength?: {
length?: number;
errorOnly?: boolean;
};
/**
* @zh `allowClear` 时配置清除按钮的图标。
* @en Configure the icon of the clear button when `allowClear`.
*/
clearIcon?: ReactNode;
/**
* @zh 是否展示输入框的字符长度限制
* @en Whether to show the character length limit of the input box
*/
showWordLimit?: boolean;
/**
* @zh 是否自动调整输入框宽度
* @en Whether to automatically adjust the width of the input box
*/
autoFitWidth?: boolean;
/**
* @zh 输入框的 ref 对象(RefInputType 类型)
* @en The ref object of the input box(RefInputType type)
*/
ref?: React.Ref;
}
export type RefInputType = {
/** 使输入框失去焦点 */
blur?: () => void;
/** 使输入框获取焦点 */
focus?: () => void;
/** input dom元素 */
inputDom?: HTMLInputElement;
/** 输入框 dom元素 */
dom?: HTMLInputElement;
};