import { ReactNode, ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, SyntheticEvent, InputHTMLAttributes, HTMLAttributes } from 'react'; import { ConfiguredComponent } from '@befe/brick-core'; import { ButtonProps } from '@befe/brick-comp-button'; import { INPUT_TYPES, InputSize, InputStatus } from './common'; import { InputWithHoverProps } from './utils/create-hover-feature'; type NativeInputProps = Omit, 'style' | 'size' | 'defaultValue' | 'prefix'>; export interface InputProps extends NativeInputProps, InputWithHoverProps { /** * 自定义 class */ className?: string; /** * 输入值 */ value?: string | number; /** * 默认值 */ defaultValue?: string | number; /** * 输入类型 */ type?: (typeof INPUT_TYPES)[number]; /** * 尺寸 * use config context `baseSize` as default */ size?: InputSize; /** * 是否禁用 */ disabled?: boolean; /** * 是否只读(样式与 disabled 一致) * @private 因为我们约定其语义和 disabled 一致 */ readOnly?: boolean; /** * 文本框状态 */ status?: InputStatus; /** * @todo * 提示内容,基本样式会跟随 status * * @private */ hint?: ReactNode; /** * @todo * 最大输入长度 * * @private */ maxLength?: number; /** * 是否提供清除按钮 */ withClear?: boolean; /** * 是否在 blur 时进行对 value 进行 trim */ trimOnBlur?: boolean; /** * 输入框内前缀 */ prefix?: ReactNode; /** * 输入框内后缀 */ suffix?: ReactNode; /** * @todo * 输入框组合的前缀部分 * * @private */ prepend?: ReactNode; /** * @todo * 输入框组合的后缀部分 * * @private */ append?: ReactNode; /** * 值变化时的回调 */ onChange?: (e: ChangeEvent | FocusEvent) => void; /** * 按下回车的回调 */ onPressEnter?: (e: KeyboardEvent) => void; /** * 按下按键的回调 */ onKeyDown?: (e: KeyboardEvent) => void; /** * 点击清除按钮的回调 */ onClickClear?: (e: MouseEvent) => void; /** * @private * 仅供内部组件使用 */ prefixInnerPadding?: number; /** * @private * 仅供内部组件使用 */ suffixInnerPadding?: number; } interface InputState { value: string | number; isHover: boolean; isFocus: boolean; } export declare const INPUT_PROP_VALUE_WARNING: string; export declare class Input extends ConfiguredComponent { static displayName: string; static defaultProps: { className: string; defaultValue: string; status: string; withClear: boolean; trimOnBlur: boolean; }; elemInput: HTMLInputElement; inputRefs: { prefix: { ref(node: HTMLDivElement | null): void; readonly elem: HTMLDivElement | null; }; suffix: { ref(node: HTMLDivElement | null): void; readonly elem: HTMLDivElement | null; }; append: { ref(node: HTMLDivElement | null): void; readonly elem: HTMLDivElement | null; }; prepend: { ref(node: HTMLDivElement | null): void; readonly elem: HTMLDivElement | null; }; }; state: { value: string | number; isHover: boolean; isFocus: boolean; }; hoverFeature: { onMouseEnter: (e: MouseEvent) => void; onMouseLeave: (e: MouseEvent) => void; }; constructor(props: InputProps); static getDerivedStateFromProps(nextProps: InputProps): Partial | null; get className(): string; get size(): "xs" | "sm" | "md" | "lg" | "xl"; get withClear(): boolean; refInput: (node: HTMLInputElement) => void; handleChange: (e: ChangeEvent, callback?: () => void) => void; handleClickClear: (e: MouseEvent) => void; handleKeyDown: (e: KeyboardEvent) => void; handleBlur: (e: FocusEvent) => void; handleFocus: (e: FocusEvent) => void; handleMouseDownClear: ButtonProps['onMouseDown']; /** * focus input element * @public */ focus(options?: FocusOptions): void; /** * blur input element * @public */ blur(): void; /** * select input element * @public */ select(): void; /** * @private * * 处理前后缀造成的 padding 问题 */ processExtraPadding(): void; simulateChangeEvent(e: SyntheticEvent, value: string, callback?: () => void): void; renderWrap(type: 'prefix' | 'suffix' | 'append' | 'prepend', wrapProps?: HTMLAttributes): import("react/jsx-runtime").JSX.Element | null; renderPrepend(): import("react/jsx-runtime").JSX.Element | null; renderAppend(): import("react/jsx-runtime").JSX.Element | null; renderPrefix(): import("react/jsx-runtime").JSX.Element | null; renderSuffix(): import("react/jsx-runtime").JSX.Element | null; /** * @todo */ renderHint(): null; renderInputWrap(): import("react/jsx-runtime").JSX.Element; renderInput(): import("react/jsx-runtime").JSX.Element; componentDidMount(): void; componentDidUpdate(): void; render(): import("react/jsx-runtime").JSX.Element; } export {};