@acusti/input-text
InputText
is a React component that renders a semi-controlled input,
meaning that while it is uncontrolled in the React sense, it’s value is
overwritten whenever props.initialValue
changes. It also support
multiline inputs (rendered as a <textarea>
) that automatically resize
vertically to fit their content.
See the storybook docs and demo to get a feel for what it can do.
Usage
npm install @acusti/input-text
# or
yarn add @acusti/input-text
Props
This is the type signature for the props you can pass to InputText
. The
unique features provided by the component are called out and explained
above the corresponding prop via JSDoc comments:
type Props = {
autoCapitalize?: 'none' | 'off' | 'sentences' | 'words' | 'characters';
autoComplete?: HTMLInputElement['autocomplete'];
className?: string;
disabled?: boolean;
doubleClickToEdit?: boolean;
enterKeyHint?: InputHTMLAttributes<HTMLInputElement>['enterKeyHint'];
form?: string;
initialValue?: string;
list?: string;
max?: number;
maxHeight?: number | string;
maxLength?: number;
min?: number;
minLength?: number;
multiLine?: boolean;
multiple?: boolean;
name?: string;
onBlur?: (event: React.FocusEvent<InputElement>) => unknown;
onChange?: (event: React.ChangeEvent<InputElement>) => unknown;
onFocus?: (event: React.FocusEvent<InputElement>) => unknown;
onKeyDown?: (event: React.KeyboardEvent<InputElement>) => unknown;
onKeyUp?: (event: React.KeyboardEvent<InputElement>) => unknown;
pattern?: string;
placeholder?: string;
readOnly?: boolean;
required?: boolean;
selectTextOnFocus?: boolean;
size?: number;
step?: number;
style?: React.CSSProperties;
submitOnEnter?: boolean;
tabIndex?: number;
title?: string;
type?:
| 'text'
| 'email'
| 'number'
| 'password'
| 'search'
| 'tel'
| 'url';
};
Note: the InputElement
type referenced in the event handlers above is a
union of HTMLInputElement
and HTMLTextAreaElement
and is available as
an export (import type { InputElement } from '@acusti/input-text';
).