diff --git a/lib/index.js b/lib/index.js index e3e464e4..17b0fcb3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -56,8 +56,8 @@ export default class PhoneInput extends Component { onChangePhoneNumber(number) { const actionAfterSetState = this.props.onChangePhoneNumber ? () => { - this.props.onChangePhoneNumber(number); - } + this.props.onChangePhoneNumber(number); + } : null; this.updateFlagAndFormatNumber(number, actionAfterSetState); } @@ -165,34 +165,39 @@ export default class PhoneInput extends Component { render() { const { iso2, formattedNumber, disabled } = this.state; - const TextComponent = this.props.textComponent || TextInput; + const { + textComponent, style, flagStyle, offset, textStyle, textProps, maxLength, pickerButtonColor, pickerButtonTextStyle, + itemStyle, cancelText, cancelTextStyle, confirmText, confirmTextStyle, pickerBackgroundColor, pickerItemStyle + } = this.props; + const TextComponent = textComponent || TextInput; return ( - + - + { this.inputPhone = ref; }} editable={!disabled} autoCorrect={false} - style={[styles.text, this.props.textStyle]} + style={[styles.text, textStyle]} onChangeText={text => { this.onChangePhoneNumber(text); }} keyboardType="phone-pad" underlineColorAndroid="rgba(0,0,0,0)" value={formattedNumber} - {...this.props.textProps} + maxLength={maxLength} + {...textProps} /> @@ -202,15 +207,15 @@ export default class PhoneInput extends Component { }} selectedCountry={iso2} onSubmit={this.selectCountry} - buttonColor={this.props.pickerButtonColor} - buttonTextStyle={this.props.pickerButtonTextStyle} - itemStyle={this.props.itemStyle} - cancelText={this.props.cancelText} - cancelTextStyle={this.props.cancelTextStyle} - confirmText={this.props.confirmText} - confirmTextStyle={this.props.confirmTextStyle} - pickerBackgroundColor={this.props.pickerBackgroundColor} - itemStyle={this.props.pickerItemStyle} + buttonColor={pickerButtonColor} + buttonTextStyle={pickerButtonTextStyle} + itemStyle={itemStyle} + cancelText={cancelText} + cancelTextStyle={cancelTextStyle} + confirmText={confirmText} + confirmTextStyle={confirmTextStyle} + pickerBackgroundColor={pickerBackgroundColor} + itemStyle={pickerItemStyle} /> );