@uiw/react-native
Version:
UIW for React Native
54 lines (53 loc) • 1.93 kB
TypeScript
import React from 'react';
import { TextInput, TextInputProps, NativeSyntheticEvent, TextInputFocusEventData, StyleProp, TextStyle, ViewStyle } from 'react-native';
export interface InputProps extends TextInputProps {
/** 限制输入条件 */
rule?: RegExp | ((value: string) => boolean);
/** 输入不合法时触发方法 */
wrongfulHandle?: Function;
/** 如果为 true,文本框是不可编辑的。默认值为 false */
disabled?: boolean;
/** 如果为 true,每次开始输入的时候都会清除文本框的内容。 */
clearText?: boolean;
/** 显示错误 */
error?: boolean;
/** 自定义错误提示 */
renderError?: React.ReactNode;
/** 边框 */
border?: 'bottom' | 'top' | 'left' | 'right' | null | 'always';
/** 边框颜色 */
borderColor?: string;
/** 是否显示清除按钮 */
clear?: boolean;
/** 清除按钮样式 */
clearStyle?: StyleProp<TextStyle>;
/** 自定义清除元素 */
renderClear?: React.ReactNode;
/** 输入框前缀的额外的信息 */
extraStart?: string | React.ReactNode;
/** 输入框末尾额外的信息 */
extraEnd?: string | React.ReactNode;
/** 容器样式 */
containerStyle?: StyleProp<ViewStyle>;
/** 输入框 ref */
inputRef?: React.RefObject<TextInput>;
}
interface InputState {
value?: string;
control: 'props' | 'state';
}
export default class Input extends React.Component<InputProps, InputState> {
ref: React.RefObject<TextInput>;
state: InputState;
static getDerivedStateFromProps(props: InputProps, state: InputState): {
control: string;
value?: undefined;
} | {
value: string | undefined;
control: string;
} | null;
onChangeText: (value: string) => false | undefined;
onFocus: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
render(): JSX.Element;
}
export {};