UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

79 lines (70 loc) 2.51 kB
import * as React from 'react'; import { StandardProps, PropTypes } from '..'; import { FormControlProps } from '../FormControl'; import { FormHelperTextProps } from '../FormHelperText'; import { InputProps as StandardInputProps } from '../Input'; import { FilledInputProps } from '../FilledInput'; import { OutlinedInputProps } from '../OutlinedInput'; import { InputLabelProps } from '../InputLabel'; import { SelectProps } from '../Select'; export interface BaseTextFieldProps extends StandardProps< FormControlProps, TextFieldClassKey, // event handlers are declared on derived interfaces 'onChange' | 'onBlur' | 'onFocus' | 'defaultValue' > { autoComplete?: string; autoFocus?: boolean; color?: 'primary' | 'secondary'; children?: React.ReactNode; defaultValue?: unknown; disabled?: boolean; error?: boolean; FormHelperTextProps?: Partial<FormHelperTextProps>; fullWidth?: boolean; helperText?: React.ReactNode; id?: string; InputLabelProps?: Partial<InputLabelProps>; inputRef?: React.Ref<any>; label?: React.ReactNode; margin?: PropTypes.Margin; multiline?: boolean; name?: string; placeholder?: string; required?: boolean; rows?: string | number; rowsMax?: string | number; select?: boolean; SelectProps?: Partial<SelectProps>; type?: string; value?: unknown; } export interface StandardTextFieldProps extends BaseTextFieldProps { onBlur?: StandardInputProps['onBlur']; onChange?: StandardInputProps['onChange']; onFocus?: StandardInputProps['onFocus']; variant?: 'standard'; InputProps?: Partial<StandardInputProps>; inputProps?: StandardInputProps['inputProps']; } export interface FilledTextFieldProps extends BaseTextFieldProps { onBlur?: FilledInputProps['onBlur']; onChange?: FilledInputProps['onChange']; onFocus?: FilledInputProps['onFocus']; variant: 'filled'; InputProps?: Partial<FilledInputProps>; inputProps?: FilledInputProps['inputProps']; } export interface OutlinedTextFieldProps extends BaseTextFieldProps { onBlur?: OutlinedInputProps['onBlur']; onChange?: OutlinedInputProps['onChange']; onFocus?: OutlinedInputProps['onFocus']; variant: 'outlined'; InputProps?: Partial<OutlinedInputProps>; inputProps?: OutlinedInputProps['inputProps']; } export type TextFieldProps = StandardTextFieldProps | FilledTextFieldProps | OutlinedTextFieldProps; export type TextFieldClassKey = 'root'; declare const TextField: React.ComponentType<TextFieldProps>; export default TextField;