UNPKG

matrix-react-sdk

Version:
63 lines (62 loc) 1.87 kB
import React, { InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react'; import { IFieldState, IValidationResult } from "./Validation"; interface IProps { id?: string; type?: string; list?: string; label?: string; placeholder?: string; prefixComponent?: React.ReactNode; postfixComponent?: React.ReactNode; onValidate?: (input: IFieldState) => Promise<IValidationResult>; forceValidity?: boolean; tooltipContent?: React.ReactNode; forceTooltipVisible?: boolean; tooltipClassName?: string; className?: string; validateOnFocus?: boolean; validateOnBlur?: boolean; validateOnChange?: boolean; } export interface IInputProps extends IProps, InputHTMLAttributes<HTMLInputElement> { element?: "input"; value: string; } interface ISelectProps extends IProps, SelectHTMLAttributes<HTMLSelectElement> { element: "select"; value: string; } interface ITextareaProps extends IProps, TextareaHTMLAttributes<HTMLTextAreaElement> { element: "textarea"; value: string; } declare type PropShapes = IInputProps | ISelectProps | ITextareaProps; interface IState { valid: boolean; feedback: React.ReactNode; feedbackVisible: boolean; focused: boolean; } export default class Field extends React.PureComponent<PropShapes, IState> { private id; private input; static readonly defaultProps: { element: string; type: string; validateOnFocus: boolean; validateOnBlur: boolean; validateOnChange: boolean; }; private validateOnChange; constructor(props: any); focus(): void; private onFocus; private onChange; private onBlur; validate({ focused, allowEmpty }: { focused?: boolean; allowEmpty?: boolean; }): Promise<boolean>; render(): JSX.Element; } export {};