react-native-masked-text
Advanced tools
Comparing version 1.3.4 to 1.4.0
import React, { Component } from 'react'; | ||
import { | ||
StyleSheet, | ||
TextInput | ||
StyleSheet, | ||
TextInput | ||
} from 'react-native'; | ||
@@ -10,5 +10,8 @@ import BaseTextComponent from './base-text-component'; | ||
let Input = TextInput | ||
export default class TextInputMask extends BaseTextComponent { | ||
constructor(props) { | ||
super(props); | ||
if (props.customTextInput) Input = props.customTextInput | ||
} | ||
@@ -23,3 +26,3 @@ | ||
if(!this._checkText(text)) { | ||
if (!this._checkText(text)) { | ||
return; | ||
@@ -30,3 +33,3 @@ } | ||
.then(maskedText => { | ||
if(self.props.onChangeText) { | ||
if (self.props.onChangeText) { | ||
self.props.onChangeText(maskedText); | ||
@@ -38,3 +41,3 @@ } | ||
_checkText(text) { | ||
if(this.props.checkText) { | ||
if (this.props.checkText) { | ||
return this.props.checkText(this.state.value, text); | ||
@@ -48,3 +51,3 @@ } | ||
return ( | ||
<TextInput | ||
<Input | ||
ref={INPUT_TEXT_REF} | ||
@@ -55,5 +58,5 @@ keyboardType={this._maskHandler.getKeyboardType()} | ||
value={this.state.value} | ||
/> | ||
/> | ||
); | ||
} | ||
} |
{ | ||
"name": "react-native-masked-text", | ||
"version": "1.3.4", | ||
"version": "1.4.0", | ||
"description": "Text and TextInput with mask for React Native applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -103,3 +103,20 @@ # react-native-masked-text | ||
**customTextInput** <br /> | ||
You can use this prop if you want custom text input instead native TextInput component: | ||
```jsx | ||
const Textfield = MKTextField.textfield() | ||
.withPlaceholder('Text...') | ||
.withStyle(styles.textfield) | ||
.build(); | ||
<TextInputMask | ||
ref={'myDateText'} | ||
type={'money'} | ||
style={styles.input} | ||
customTextInput={Textfield} | ||
placeholder="Enter text to see events" /> | ||
``` | ||
**TextInput Props** <br /> | ||
@@ -289,2 +306,5 @@ You can use the native props of TextInput, with this in mind: | ||
# Changelog | ||
## 1.4.0 | ||
* Adding `customTextInput` to allow other inputs instead native TextInput. (thank to [Hellon Canella](https://github.com/helloncanella)) | ||
## 1.3.4 | ||
@@ -291,0 +311,0 @@ * Remove default value from mask to allow placeholder on text-input (thanks to [Cuong Hoang](https://github.com/cuonghv91)). |
57395
1374
349