@coconut-software/ui
Version:
React components for faster and easier web development.
51 lines (50 loc) • 2.13 kB
TypeScript
import type { ChangeEvent, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, ReactNode, Ref } from 'react';
import React from 'react';
import type { TextInputSize, TextInputVariant, TextInputColor } from './styles';
type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
type InputMode = 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
type SvgIconComponent = {
uiName: 'SvgIcon';
(props: {
color: string;
}): JSX.Element;
};
export interface TextInputProps {
appearFocused?: boolean;
autoFocus?: boolean;
color?: TextInputColor;
containerRef?: Ref<HTMLLabelElement>;
dataSet?: Record<string, string | undefined>;
defaultValue?: string;
disabled?: boolean;
endAdornment?: SvgIconComponent | string | ReactNode;
enterKeyHint?: EnterKeyHint;
error?: boolean;
helperText?: string;
inputMode?: InputMode;
inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;
label: string;
lines?: number;
max?: string | number;
maxLines?: number;
min?: string | number;
multiline?: boolean;
name?: string;
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onClear?: MouseEventHandler<HTMLButtonElement>;
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onChange?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
onClick?: MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onKeyDown?: KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
readOnly?: boolean;
required?: boolean;
selectable?: boolean;
size?: TextInputSize;
startAdornment?: SvgIconComponent | string | ReactNode;
tabIndex?: number;
type?: TextInputType;
variant?: TextInputVariant;
}
type TextInputType = 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url' | 'color';
declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLDivElement>>;
export default TextInput;