import type { TextInputProps as RNTextInputProps, StyleProp, ViewStyle, TextStyle, TextInput as RNTextInput, FocusEvent, BlurEvent, } from 'react-native'; import type { IconName } from '@hero-design/rn'; export type TextInputHandles = Pick< RNTextInput, 'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps' >; export type TextInputVariant = 'text' | 'textarea'; export type NativeTextInputProps = Omit< RNTextInputProps, 'onFocus' | 'onBlur' > & { onFocus?: (event?: FocusEvent) => void | undefined; onBlur?: (event?: BlurEvent) => void | undefined; }; export interface TextInputRef { focus: () => void; blur: () => void; clear: () => void; isFocused: () => boolean; setNativeProps?: (props: RNTextInputProps) => void; } export type TextInputProps = NativeTextInputProps & { /** * Field label. */ label?: string; /** * Name of Icon or ReactElement to render on the left side of the input, before the user's cursor. */ prefix?: IconName | React.ReactElement; /** * Name of Icon or ReactElement to render on the right side of the input. */ suffix?: IconName | React.ReactElement; /** * Additional wrapper style. */ style?: StyleProp; /** * Input text style. */ textStyle?: StyleProp; /** * Testing id of the component. */ testID?: string; /** * Accessibility label for the input (Android). */ accessibilityLabelledBy?: string; /** * Error message to display. */ error?: string; /** * Whether the input is required. When false, "(Optional)" will be appended to the label. */ required?: boolean; /** * Placeholder text to display. * */ placeholder?: string; /** * Whether the input is editable. * */ editable?: boolean; /** * Whether the input is disabled. */ disabled?: boolean; /** * Whether the input is loading. */ loading?: boolean; /** * The max length of the input. * If the max length is set, the input will display the current length and the max length. * */ maxLength?: number; /** * Whether to hide the character count. * */ hideCharacterCount?: boolean; /** * The helper text to display. */ helpText?: string; /** * Customise input value renderer */ renderInputValue?: ( inputProps: NativeTextInputProps, ref?: React.ForwardedRef ) => React.ReactNode; /** * Component ref. */ ref?: React.Ref; /** * Component variant. */ variant?: TextInputVariant; }; export interface InternalTextInputProps extends TextInputProps { /** * Whether to use the group style. */ groupStyleEnabled?: boolean; }