UNPKG

3.67 kBTypeScriptView Raw
1import * as React from 'react';
2import Group from './Group';
3import Search from './Search';
4import TextArea from './TextArea';
5import Password from './Password';
6import { Omit, LiteralUnion } from '../_util/type';
7import ClearableLabeledInput from './ClearableLabeledInput';
8import { ConfigConsumerProps, DirectionType } from '../config-provider';
9import { SizeType } from '../config-provider/SizeContext';
10export interface InputFocusOptions extends FocusOptions {
11 cursor?: 'start' | 'end' | 'all';
12}
13export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'type'> {
14 prefixCls?: string;
15 size?: SizeType;
16 type?: LiteralUnion<'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week', string>;
17 onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
18 addonBefore?: React.ReactNode;
19 addonAfter?: React.ReactNode;
20 prefix?: React.ReactNode;
21 suffix?: React.ReactNode;
22 allowClear?: boolean;
23 bordered?: boolean;
24}
25export declare function fixControlledValue<T>(value: T): "" | T;
26export declare function resolveOnChange<E extends HTMLInputElement | HTMLTextAreaElement>(target: E, e: React.ChangeEvent<E> | React.MouseEvent<HTMLElement, MouseEvent> | React.CompositionEvent<HTMLElement>, onChange: undefined | ((event: React.ChangeEvent<E>) => void), targetValue?: string): void;
27export declare function getInputClassName(prefixCls: string, bordered: boolean, size?: SizeType, disabled?: boolean, direction?: DirectionType): string;
28export declare function triggerFocus(element?: HTMLInputElement | HTMLTextAreaElement, option?: InputFocusOptions): void;
29export interface InputState {
30 value: any;
31 focused: boolean;
32 /** `value` from prev props */
33 prevValue: any;
34}
35declare class Input extends React.Component<InputProps, InputState> {
36 static Group: typeof Group;
37 static Search: typeof Search;
38 static TextArea: typeof TextArea;
39 static Password: typeof Password;
40 static defaultProps: {
41 type: string;
42 };
43 input: HTMLInputElement;
44 clearableInput: ClearableLabeledInput;
45 removePasswordTimeout: any;
46 direction: DirectionType;
47 constructor(props: InputProps);
48 static getDerivedStateFromProps(nextProps: InputProps, { prevValue }: InputState): Partial<InputState>;
49 componentDidMount(): void;
50 componentDidUpdate(): void;
51 getSnapshotBeforeUpdate(prevProps: InputProps): null;
52 componentWillUnmount(): void;
53 focus: (option?: InputFocusOptions | undefined) => void;
54 blur(): void;
55 setSelectionRange(start: number, end: number, direction?: 'forward' | 'backward' | 'none'): void;
56 select(): void;
57 saveClearableInput: (input: ClearableLabeledInput) => void;
58 saveInput: (input: HTMLInputElement) => void;
59 onFocus: React.FocusEventHandler<HTMLInputElement>;
60 onBlur: React.FocusEventHandler<HTMLInputElement>;
61 setValue(value: string, callback?: () => void): void;
62 handleReset: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
63 renderInput: (prefixCls: string, size: SizeType | undefined, bordered: boolean, input?: ConfigConsumerProps['input']) => JSX.Element;
64 clearPasswordValueAttribute: () => void;
65 handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
66 handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
67 renderComponent: ({ getPrefixCls, direction, input }: ConfigConsumerProps) => JSX.Element;
68 render(): JSX.Element;
69}
70export default Input;