From 1c87848971e6783e24f601bdb6c8286a3084d90a Mon Sep 17 00:00:00 2001 From: Ben-hur Santos Ott Date: Sat, 23 Feb 2019 14:26:11 -0300 Subject: [PATCH 1/9] test(readme): testing iframe --- README.md | 381 +-------------------------------------- README.old.md | 490 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 494 insertions(+), 377 deletions(-) create mode 100644 README.old.md diff --git a/README.md b/README.md index 64196711..d48247a4 100644 --- a/README.md +++ b/README.md @@ -17,386 +17,13 @@ React-native: 0.32.0 or higher ## Usage (TextInputMask) -```jsx -import React, { Component } from 'react' - -// import the component -import { TextInputMask } from 'react-native-masked-text' - -export default class MyComponent extends Component { - constructor(props) { - super(props) - } - - componentDidMount() { - // isValid method returns if the inputed value is valid. - // Ex: if you input 40/02/1990 30:20:20, it will return false - // because in this case, the day and the hour is invalid. - let valid = this.myDateText.isValid(); - - // get converted value. Using type=datetime, it returns the moment object. - // If it's using type=money, it returns a Number object. - let rawValue = this.myDateText.getRawValue(); - } - - render() { - // the type is required but options is required only for some specific types. - return ( - this.myDateText = ref} - type={'datetime'} - options={{ - format: 'DD-MM-YYYY HH:mm:ss' - }} - /> - ) - } -} -``` - -### Props - -#### type - -_credit-card_: use the mask 9999 9999 9999 9999. It accepts options (see later in this doc).
-_cpf_: use the mask `999.999.999-99` and `numeric` keyboard.
-_cnpj_: use the mask `99.999.999/9999-99` and `numeric` keyboard.
-_zip-code_: use the mask `99999-999` and `numeric` keyboard.
-_only-numbers_: accept only numbers on field with `numeric` keyboard.
-_money_: use the mask `R$ 0,00` on the field with `numeric` keyboard. It accepts options (see later in this doc).
-_cel-phone_: use the mask `(99) 9999-9999` or `(99) 99999-9999` (changing automaticaly by length). It accepts options (see later in this doc).
-_datetime_: use datetime mask with moment format (default DD/MM/YYYY HH:mm:ss). It accepts options (see later in this doc).
-_custom_: use your custom mask (see the options props later in this doc).
- -#### onChangeText - -Invoked after new value applied to mask. - -```jsx -/** - * @param {String} text the text AFTER mask is applied. -*/ -onChangeText(text) { - // ... -} - - -``` - -#### checkText - -Allow you to check and prevent value to be inputed. - -```jsx -/** - * @param {String} previous the previous text in the masked field. - * @param {String} next the next text that will be setted to field. - * @return {Boolean} return true if must accept the value. -*/ -checkText(previous, next) { - return next === 'your valid value or other boolean condition'; -} - - -``` - -#### customTextInput - -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(); - - - this.myDateText = ref} - type={'money'} - style={styles.input} - customTextInput={Textfield} - placeholder="Enter text to see events" -/> -``` - -#### customTextInputProps - -Some custom inputs like [react-native-textinput-effects](https://github.com/halilb/react-native-textinput-effects) have to set properties in mount time. For these types of components we use this property. - -```jsx -import React from 'react' -import { StyleSheet, View } from 'react-native' - -import { TextInputMask } from 'react-native-masked-text' -import { Kaede } from 'react-native-textinput-effects' - -export default class App extends React.Component { - constructor(props) { - super(props) - - this.state = { - birthday: '' - } - } - - render() { - return ( - - this.myDateText = ref} - // here we set the custom component and their props. - customTextInput={Kaede} - customTextInputProps={{ - style:{ width: '80%' }, - label:'Birthday' - }} - - type={'datetime'} - options={{ - format: 'DD-MM-YYYY HH:mm:ss' - }} - - // don't forget: the value and state! - onChangeText={birthday => this.setState({ birthday })} - value={this.state.birthday} /> - - ); - } -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#fff', - alignItems: 'center', - justifyContent: 'center' - } -}) -``` - -#### TextInput Props +### CPF -You can use the native props of TextInput, with this in mind: +Mask: `999.999.999-99` -- onChangeText is intercepted by component. -- value is intercepted by component. -- if you pass keyboardType, it will override the keyboardType of masked component. +Sample code: -#### TextInput Methods - -If you want to use the methods of the native TextInput, use the `getElement()` method: - -```jsx -export default class App extends React.Component { - onGoFocus() { - // when you call getElement method, the instance of native TextInput will returned. - this._myTextInputMask.getElement().focus() - } - - render() { - return ( - - - (this._myTextInputMask = ref)} - type={'only-numbers'} - style={styles.input} - /> - - -