import { ReactNode, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';
import { type SizeType } from '../config-provider';
/**
* @title Input
* **Input 接受所有原生的属性值**
*/
export interface InputProps extends Omit, 'onChange' | 'prefix' | 'className' | 'size' | 'height' | 'maxLength' | 'clearable'> {
style?: CSSProperties;
className?: string | string[];
/**
* 允许清空输入框
*/
allowClear?: boolean;
/**
* 自动获取焦点
*/
autoFocus?: boolean;
/**
* 是否禁用
*/
disabled?: boolean;
/**
* 是否只读
*/
readOnly?: boolean;
/**
* 静态展示
*/
quickStatic?: boolean;
/**
* 快速编辑(默认无边框)
*/
quickEdit?: boolean;
/**
* 纯展示
*/
showValue?: boolean;
clearable?: boolean;
quickStaticStr?: boolean;
staticPlaceholder?: string;
/**
* 默认值
*/
defaultValue?: string;
/**
* 占位提示语
*/
placeholder?: string;
/**
* 状态
*/
status?: 'error' | 'warning';
/**
* 设置宽度自适应。minWidth 默认为 0,maxWidth 默认为 100%
*/
autoWidth?: boolean | {
minWidth?: CSSProperties['minWidth'];
maxWidth?: CSSProperties['maxWidth'];
};
minWidth?: CSSProperties['minWidth'];
maxWidth?: CSSProperties['minWidth'];
/**
* 输入时的回调
*/
onChange?: (value: string, e: any) => void;
/**
* 点击清除按钮的回调
*/
onClear?: () => void;
/**
* 按下回车键的回调
*/
onPressEnter?: (e: any) => void;
/**
* 指定 normalize 执行的时机
* @defaultValue ['onBlur']
*/
normalizeTrigger?: ('onBlur' | 'onPressEnter')[];
/**
* 在指定时机对用户输入的值进行格式化处理。前后值不一致时,会触发 onChange
*/
normalize?: (value: string) => string;
/**
* 输入框前添加元素
*/
addBefore?: ReactNode;
/**
* 输入框后添加元素
*/
addAfter?: ReactNode;
/**
* 添加前缀文字或者图标
*/
prefix?: ReactNode;
/**
* 添加后缀文字或者图标
*/
suffix?: ReactNode;
/**
* 输入框的值,受控模式
*/
value?: string;
/**
* 输入框前添加元素的样式
*/
beforeStyle?: object;
/**
* 输入框后添加元素的样式
*/
afterStyle?: object;
/**
* 输入框的尺寸
* @defaultValue middle
*/
size?: SizeType;
/**
* 自定义输入框高度
*/
height?: number | string;
/**
* 输入框最大输入的长度;设置 `errorOnly`为 `true` 后,超过 `maxLength` 会展示 `error` 状态,并不限制用户输入。
*/
maxLength?: number;
/**
* `errorOnly`为 `true` 后,超过 `maxLength` 会展示 `error` 状态,并不限制用户输入。
*/
errorOnly?: boolean;
/**
* 配合 `maxLength`,显示字数统计
*/
showWordLimit?: boolean;
/**
* `allowClear` 时配置清除按钮的图标。
*/
clearIcon?: ReactNode;
}
/**
* @title Input.TextArea
*/
export interface TextAreaProps extends Omit, 'onChange' | 'className' | 'maxLength'> {
style?: CSSProperties;
/**
* 开启字数统计之后,会在 `textarea` 标签外包一层 `div`,`wrapperStyle` 用来配置这个 `div` 的样式。
*/
wrapperStyle?: CSSProperties;
className?: string | string[];
/**
* 是否禁用
*/
disabled?: boolean;
/**
* 静态模式
*/
quickStatic?: boolean;
/**
* 快速编辑(默认无边框)
*/
quickEdit?: boolean;
/**
* 默认值
*/
defaultValue?: string;
/**
* 值
*/
value?: string;
/**
* 是否自动调整输入框的高度
*/
autoSize?: boolean | {
minRows?: number;
maxRows?: number;
};
/**
* 状态
*/
status?: 'error' | 'warning';
/**
* 输入框提示文字
*/
placeholder?: string;
/**
* 输入时的回调
*/
onChange?: (value: string, e: any) => void;
/**
* 按下回车键的回调
*/
onPressEnter?: (e: any) => void;
/**
* 输入框最大输入的长度;设置 `errorOnly`为 `true` 后,超过 `maxLength` 会展示 `error` 状态,并不限制用户输入。
*/
maxLength?: number;
/**
* 配合 `maxLength`,显示字数统计
*/
showWordLimit?: boolean;
/**
* `errorOnly`为 `true` 后,超过 `maxLength` 会展示 `error` 状态,并不限制用户输入。
*/
errorOnly?: boolean;
/**
* 允许清空输入框
*/
allowClear?: boolean;
/**
* 点击清除按钮的回调
*/
onClear?: () => void;
/**
* `allowClear` 时配置清除按钮的图标。
*/
clearIcon?: ReactNode;
}
/**
* @title Input.Group
*/
export interface InputGroupProps {
style?: CSSProperties;
className?: string | string[];
/**
* 是否使用紧凑模式
*/
compact?: boolean;
}
/**
* @title Input.Search
* 包含 Input 组件所有参数
*/
export interface InputSearchProps extends InputProps {
/**
* 搜索时展示加载状态
*/
loading?: boolean;
/**
* 点击搜索按钮的回调
*/
onSearch?: (value: string) => void;
/**
* 搜索按钮
*/
searchButton?: boolean | ReactNode;
}
/**
* @title Input.Password
* 包含 Input 组件所有参数
*/
export interface InputPasswordProps extends InputProps {
/**
* 是否显示切换密码可见状态的按钮
*/
visibilityToggle?: boolean;
/**
* 初始是否显示
*/
defaultVisibility?: boolean;
/**
* 是否显示
*/
visibility?: boolean;
/**
* visibility 改变时触发
*/
onVisibilityChange?: (visibility: boolean) => void;
}
export interface InputComponentProps extends InputProps {
prefixCls?: string;
hasParent?: boolean;
autoFitWidth?: boolean | {
minWidth?: CSSProperties['minWidth'];
maxWidth?: CSSProperties['maxWidth'];
pure?: boolean;
delay: number | ((width: number, prevWidth: number) => number);
inputContentWidth?: number;
};
}
export declare type RefInputType = {
/** 使输入框失去焦点 */
blur: () => void;
/** 使输入框获取焦点 */
focus: () => void;
/** input dom元素 */
dom: HTMLInputElement;
};