import * as React from "react"; import { Animated, TextInput as NativeTextInput, StyleProp, TextStyle } from "react-native"; import type { RenderProps, State } from "./types"; import { DefaultTheme } from "styled-components"; export declare type TextInputProps = React.ComponentPropsWithRef & { /** * Mode of the TextInput. * - `flat` - flat input with an underline. * - `outlined` - input with an outline. * * In `outlined` mode, the background color of the label is derived from `colors.background` in theme or the `backgroundColor` style. * This component render TextInputOutlined or TextInputFlat based on that props */ mode?: "flat" | "outlined"; left?: React.ReactNode; right?: React.ReactNode; /** * If true, user won't be able to interact with the component. */ disabled?: boolean; /** * The text to use for the floating label. */ label?: string; /** * Placeholder for the input. */ placeholder?: string; /** * Whether to style the TextInput with error style. */ error?: boolean; /** * Callback that is called when the text input's text changes. Changed text is passed as an argument to the callback handler. */ onChangeText?: (val?: any) => void; /** * Selection color of the input */ selectionColor?: string; /** * Underline color of the input. */ underlineColor?: string; /** * Sets min height with densed layout. For `TextInput` in `flat` mode * height is `64dp` or in dense layout - `52dp` with label or `40dp` without label. * For `TextInput` in `outlined` mode * height is `56dp` or in dense layout - `40dp` regardless of label. * When you apply `heigh` prop in style the `dense` prop affects only `paddingVertical` inside `TextInput` */ dense?: boolean; /** * Whether the input can have multiple lines. */ multiline?: boolean; /** * The number of lines to show in the input (Android only). */ numberOfLines?: number; /** * Callback that is called when the text input is focused. */ onFocus?: (args: any) => void; /** * Callback that is called when the text input is blurred. */ onBlur?: (args: any) => void; /** * * Callback to render a custom input component such as `react-native-text-input-mask` * instead of the default `TextInput` component from `react-native`. * * Example: * ```js * * * } * /> * ``` */ render?: (props: RenderProps) => React.ReactNode; /** * Value of the text input. */ value?: string; /** * Pass `fontSize` prop to modify the font size inside `TextInput`. * Pass `height` prop to set `TextInput` height. When `height` is passed, * `dense` prop will affect only input's `paddingVertical`. * Pass `paddingHorizontal` to modify horizontal padding. * This can be used to get MD Guidelines v1 TextInput look. */ style?: StyleProp; /** * @optional */ theme?: DefaultTheme; }; /** * A component to allow users to input text. * *
*
* *
Flat (focused)
*
*
* *
Flat (disabled)
*
*
* *
Outlined (focused)
*
*
* *
Outlined (disabled)
*
*
* * ## Usage * ```js * import * as React from 'react'; * import TextInput from 'react-native-simple-elements/components/TextInput'; * * const MyComponent = () => { * const [text, setText] = React.useState(''); * * return ( * setText(text)} * /> * ); * }; * * export default MyComponent; * ``` * * @extends TextInput props https://reactnative.dev/docs/textinput#props */ declare class TextInput extends React.Component { static contextType: any; static defaultProps: Partial; static getDerivedStateFromProps(nextProps: TextInputProps, prevState: State): { value: string; }; validInputValue: string; state: { labeled: Animated.Value; error: Animated.Value; focused: boolean; placeholder: string; value: string; labelLayout: { measured: boolean; width: number; height: number; }; leftLayout: { width: any; height: any; }; rightLayout: { width: any; height: any; }; }; ref: NativeTextInput | undefined | null; componentDidUpdate(prevProps: TextInputProps, prevState: State): void; componentWillUnmount(): void; private showPlaceholder; private hidePlaceholder; private timer?; private root; private showError; private hideError; private restoreLabel; private minimizeLabel; private onLeftAffixLayoutChange; private onRightAffixLayoutChange; private handleFocus; private handleBlur; private handleChangeText; private handleLayoutAnimatedText; forceFocus: () => void; /** * @internal */ setNativeProps(args: Record): void; /** * Returns `true` if the input is currently focused, `false` otherwise. */ isFocused(): boolean; /** * Removes all text from the TextInput. */ clear(): void; /** * Focuses the input. */ focus(): void; /** * Removes focus from the input. */ blur(): void; render(): JSX.Element; } export default TextInput;