in src/components/select/select-with-custom-input.tsx [26:54]
renderInputValueItem() {
const {onSelect, customInputValidator, customInputPlaceholder} = this.props as ISelectWithCustomInput<T>;
const {customInput, customInputError} = this.state;
return customInput !== undefined ? (
<View>
<TextInput
placeholder={customInputPlaceholder}
style={[styles.customInput, styles.headerText, customInputError ? styles.error : null]}
value={customInput}
onSubmitEditing={e => {
if (!customInputError) {
onSelect(e.nativeEvent.text);
}
}}
onChangeText={(text: string) => {
let isInvalid = false;
if (customInputValidator && text) {
if (customInputValidator instanceof RegExp) {
isInvalid = !customInputValidator.test(text);
} else if (typeof customInputValidator === 'function') {
isInvalid = !customInputValidator(text);
}
}
this.setState({customInput: text, customInputError: isInvalid});
}}
/>
</View>
) : null;
}