import { forwardRef } from 'react';
import { TextInput, View } from 'react-native';
import type { RsSkinlessTextInputProps } from '../../types/props';

type TextInputRef = TextInput;

const RsTextInput = forwardRef<TextInputRef, RsSkinlessTextInputProps>(
  (
    {
      value,
      onChangeText,
      placeholder,
      secureTextEntry,
      multiline,
      maxLength,
      keyboardType,
      autoCapitalize,
      style,
      textStyle,
      editable,
      onFocus,
      onBlur,
    },
    ref
  ) => {
    return (
      <View style={style}>
        <TextInput
          ref={ref}
          value={value}
          onChangeText={onChangeText}
          placeholder={placeholder}
          secureTextEntry={secureTextEntry}
          multiline={multiline}
          maxLength={maxLength}
          keyboardType={keyboardType}
          autoCapitalize={autoCapitalize}
          style={textStyle}
          editable={editable}
          onFocus={onFocus}
          onBlur={onBlur}
        />
      </View>
    );
  }
);

RsTextInput.displayName = 'RsTextInput';

export default RsTextInput;
