vcc-ui
Version:
A React library for building user interfaces at Volvo Cars
51 lines (47 loc) • 1.23 kB
TypeScript
import {
ChangeEventHandler,
ForwardRefExoticComponent,
InputHTMLAttributes,
RefAttributes,
} from 'react';
export type TextInputType =
| 'date'
| 'datetime-local'
| 'email'
| 'month'
| 'number'
| 'password'
| 'search'
| 'tel'
| 'text'
| 'time'
| 'url'
| 'week';
export type TextInputProps = {
/**
* The type of the input.
*
* @default text
*/
type?: TextInputType;
/** Renders a label inside the input. */
label: string;
/** Renders a description text underneath the input. */
description?: string;
/** Renders a red error message for validation underneath the input. */
errorMessage?: string;
/** onChange handler. Triggers on every keyboard and generally
* is where you update the state holding the `value` property. */
onChange: ChangeEventHandler<HTMLInputElement>;
/**
* Value of the TextInput, controlled in the state of a parent component.
*/
value: string;
/** Renders the input as valid or invalid. */
isValid?: boolean;
loading?: boolean;
disabled?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> &
RefAttributes<HTMLInputElement>;
export const TextInput: ForwardRefExoticComponent<TextInputProps>;
export {};