UNPKG

ontime-components

Version:
67 lines (66 loc) 1.99 kB
import React, { PureComponent } from 'react'; import { IProps } from '../../libs/interfaces'; import { TFuncClick, TFuncChange, TFuncFocus } from '../../libs/types'; import { TError } from '../InputErrors'; declare type TLabelPosition = 'top' | 'left' | 'right'; declare type TType = 'text' | 'number' | 'email' | 'password' | 'tel'; declare type TSize = 'large' | 'medium' | 'small' | 'smaller'; interface IInputProps extends IProps { label?: string; labelPosition?: TLabelPosition; required?: boolean; type?: TType; size?: TSize; id?: string; name?: string; leftIcon?: string; rightIcon?: string; value?: string | number; placeholder?: string; pattern?: string; mask?: string; autoFocus?: boolean; disabled?: boolean; tabIndex?: string | number; errors?: TError[] | null; format?: Function; onClick?: Function; onChange?: Function; onFocus?: Function; onBlur?: Function; onKeyDown?: Function; onLeftIconClick?: Function; onRightIconClick?: Function; } interface IInputDefProps { labelPosition: TLabelPosition; type: TType; size: TSize; } interface IInputState { value: string | number; isFocused: boolean; } declare class Input extends PureComponent<IInputProps & IInputDefProps, IInputState> { static defaultProps: IInputDefProps; readonly state: IInputState; constructor(props: IInputProps & IInputDefProps); value: React.ReactText; onClick: TFuncClick; onChange: TFuncChange; onFocus: TFuncFocus; onBlur: TFuncFocus; onKeyDown: TFuncClick; onLeftIconClick: TFuncClick; onRightIconClick: TFuncClick; focus(): void; blur(): void; isActive(): boolean; renderLeftIcon(): JSX.Element | null; renderRightIcon(): JSX.Element | null; renderLabel(): JSX.Element; renderErrors(): JSX.Element | null; renderInput(): JSX.Element; render(): JSX.Element; } export { Input, IInputProps, IInputState };