diff --git a/.babelrc b/.babelrc index a9ce1369..ae09dd2a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["react-native"] + "presets": ["react-native"] } diff --git a/.buckconfig b/.buckconfig new file mode 100644 index 00000000..934256cb --- /dev/null +++ b/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..d42ff183 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/.gitignore b/.gitignore index 004d447a..0cbf3701 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ node_modules/ .idea/ npm-debug.log -poc.js +__tst.js diff --git a/.npmignore b/.npmignore index 5bf515b8..694faabc 100644 --- a/.npmignore +++ b/.npmignore @@ -2,3 +2,10 @@ node_modules/ .vscode/ .idea/ npm-debug.log +android/ +ios/ +App.js +app.json +index.js +.watchmanconfig +.buckconfig \ No newline at end of file diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/App.js b/App.js new file mode 100644 index 00000000..8029a171 --- /dev/null +++ b/App.js @@ -0,0 +1,85 @@ +/** + * Sample React Native App + * https://github.com/facebook/react-native + * @flow + */ + +import React, { Component } from 'react' +import { StyleSheet, View } from 'react-native' +import { TextInputMask } from './rnmt' + +export default class App extends Component { + state = { + datetime: '', + creditCard: '', + custom: '', + money: '' + } + render() { + return ( + + this.setState({ datetime })} + /> + { + this.setState({ creditCard }) + console.log(this.state) + }} + /> + { + this.setState({ custom }) + console.log(this.state) + }} + /> + { + this.setState({ money }) + console.log(this.state) + }} + /> + + ) + } +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#F5FCFF' + }, + input: { + height: 50, + width: '80%', + borderColor: 'steelblue', + borderWidth: 2 + } +}) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0bb6b09..2df3536f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,115 +1,129 @@ # Changelog +## [1.9.0] - 2018-09-08 + +## Changed + +- Custom Mask: now all the masks use the core from Custom Mask. +- Adding some docs about how to use methods. + +### PRs + +- [74 - Updated Typescript definition file](https://github.com/benhurott/react-native-masked-text/pull/74). (thanks to [iiandrade](https://github.com/iiandrade)) +- [80 - TypeScript support for custom mask options](https://github.com/benhurott/react-native-masked-text/pull/80). (thanks to [enagorny](https://github.com/enagorny)) +- [88 - Moved typings dependencies to devDependencies](https://github.com/benhurott/react-native-masked-text/pull/88). (thanks to [emiyake](https://github.com/emiyake)) +- [90 - add cpf-cnpj mask to auto-detect if the document is a CPF or CNPJ](https://github.com/benhurott/react-native-masked-text/pull/90). (thanks to [ronaldozanoni](https://github.com/ronaldozanoni)) + ## 1.7.2 -* Fixing [ISSUE#79](https://github.com/benhurott/react-native-masked-text/issues/79). (thanks to [herlan-evocorp](https://github.com/herlan-evocorp)) +- Fixing [ISSUE#79](https://github.com/benhurott/react-native-masked-text/issues/79). (thanks to [herlan-evocorp](https://github.com/herlan-evocorp)) ## 1.7.1 -* Updating moment lib. +- Updating moment lib. ## 1.7.0 -* Adding `ts definitions`. (thanks to [iiandrade](https://github.com/iiandrade)) -* Adding `toRawValue` method to MaskService. (thanks to [fabioh8010](https://github.com/fabioh8010)) -* Replace old legacy ref string by the new callback. (thanks to [Yamilquery](https://github.com/Yamilquery)) +- Adding `ts definitions`. (thanks to [iiandrade](https://github.com/iiandrade)) +- Adding `toRawValue` method to MaskService. (thanks to [fabioh8010](https://github.com/fabioh8010)) +- Replace old legacy ref string by the new callback. (thanks to [Yamilquery](https://github.com/Yamilquery)) ## 1.6.5 -* Fixing validation for CPF and CNPJ when empty string is inputed. (thanks to [gabuael](https://github.com/gabuael)) +- Fixing validation for CPF and CNPJ when empty string is inputed. (thanks to [gabuael](https://github.com/gabuael)) ## 1.6.4 -* Fixing wrong format when use money mask and values with only one decimal place (`1.9`) (thanks to [Pablo](https://github.com/rochapablo)). +- Fixing wrong format when use money mask and values with only one decimal place (`1.9`) (thanks to [Pablo](https://github.com/rochapablo)). ## 1.6.3 -* Fixing moment version (thanks to [Edward Coleridge Smith](https://github.com/edcs)) -* Adding pre-builded lib to improve build phase (thanks to [Giorgi Bagdavadze](https://github.com/notgiorgi)) +- Fixing moment version (thanks to [Edward Coleridge Smith](https://github.com/edcs)) +- Adding pre-builded lib to improve build phase (thanks to [Giorgi Bagdavadze](https://github.com/notgiorgi)) ## 1.6.2 -* Fixing custom mask when removing value in middle of the text. (thanks to [Aleksandr Kompaniets](https://github.com/Oxyaction)) - _ KNOW ISSUE: the custom mask is not allowing user to input white spaces for `_` translation temporarily. +- Fixing custom mask when removing value in middle of the text. (thanks to [Aleksandr Kompaniets](https://github.com/Oxyaction)) + _ KNOW ISSUE: the custom mask is not allowing user to input white spaces for `_` translation temporarily. ## 1.6.1 -* Fixing duplicated custom text input component. (thanks to [Pablo](https://github.com/rochapablo)) +- Fixing duplicated custom text input component. (thanks to [Pablo](https://github.com/rochapablo)) ## 1.6.0 -* Add compatibility to [react-native-textinput-effects](https://github.com/halilb/react-native-textinput-effects) by using `customTextInputProps` (thanks to [Pablo](https://github.com/rochapablo)) +- Add compatibility to [react-native-textinput-effects](https://github.com/halilb/react-native-textinput-effects) by using `customTextInputProps` (thanks to [Pablo](https://github.com/rochapablo)) ## 1.5.3 -* Fix suffix backspace (thanks to [Thomas Kekeisen](https://github.com/blaues0cke)) -* Fix last character on custom mask (thanks to [Daniel Maly](https://github.com/DanielMaly)) +- Fix suffix backspace (thanks to [Thomas Kekeisen](https://github.com/blaues0cke)) +- Fix last character on custom mask (thanks to [Daniel Maly](https://github.com/DanielMaly)) ## 1.5.2 -* Adding `keyboardType` to custom mask. (thanks to [Nurbek Abulgazin](https://github.com/nurbek-ab)) +- Adding `keyboardType` to custom mask. (thanks to [Nurbek Abulgazin](https://github.com/nurbek-ab)) ## 1.5.1 -* Adding `tinymask` to fix some custom mask issues. +- Adding `tinymask` to fix some custom mask issues. ## 1.5.0 -* Adding new and powerfull `custom` engine mask \m/. +- Adding new and powerfull `custom` engine mask \m/. ## 1.4.0 -* Adding `customTextInput` to allow other inputs instead native TextInput. (thanks to [Hellon Canella](https://github.com/helloncanella)) +- Adding `customTextInput` to allow other inputs instead native TextInput. (thanks to [Hellon Canella](https://github.com/helloncanella)) ## 1.3.4 -* Remove default value from mask to allow placeholder on text-input (thanks to [Cuong Hoang](https://github.com/cuonghv91)). \* Please, caution. This can cause some runtime breaking if you update to this version. +- Remove default value from mask to allow placeholder on text-input (thanks to [Cuong Hoang](https://github.com/cuonghv91)). \* Please, caution. This can cause some runtime breaking if you update to this version. ## 1.3.3 -* Update dependencies (thanks to [Vlad-Zhukov](https://github.com/Vlad-Zhukov)) +- Update dependencies (thanks to [Vlad-Zhukov](https://github.com/Vlad-Zhukov)) ## 1.3.2 -* Fix: ignoring Jet Brains ide files (thanks to [Vlad-Zhukov](https://github.com/Vlad-Zhukov)) +- Fix: ignoring Jet Brains ide files (thanks to [Vlad-Zhukov](https://github.com/Vlad-Zhukov)) ## 1.3.1 -* Performance: adding check if the next value to be applied to the mask is equal as actual and prevent state change. +- Performance: adding check if the next value to be applied to the mask is equal as actual and prevent state change. ## 1.3.0 -* Feat: now you can check and prevent input text on `TextInputMask` using `checkText` prop. +- Feat: now you can check and prevent input text on `TextInputMask` using `checkText` prop. ## 1.2.2 -* Fix: fixing es2015 preset (thanks to [vagnercsouza](https://github.com/vagnercsouza), [barakcoh](https://github.com/barakcoh), Marvin Santos) +- Fix: fixing es2015 preset (thanks to [vagnercsouza](https://github.com/vagnercsouza), [barakcoh](https://github.com/barakcoh), Marvin Santos) ## 1.2.1 -* Fix: fixing white space after unit on money mask. +- Fix: fixing white space after unit on money mask. ## 1.2.0 -* Adding `getRawValue`. +- Adding `getRawValue`. ## 1.1.1 -* Fixing toolbox-service reference (thanks to [ziftinpeki](https://github.com/ziftinpeki)). +- Fixing toolbox-service reference (thanks to [ziftinpeki](https://github.com/ziftinpeki)). ## 1.1.0 -* Adding credit-card mask. -* Refactoring base mask to contain helpfull functions. +- Adding credit-card mask. +- Refactoring base mask to contain helpfull functions. ## 1.0.0 -* Adding datetime and cnpj masks. -* [Breaking Change] Refactoring MaskService. -* Separate mask handlers for better extensibility. -* Adding tests for all mask handlers. -* Refactoring Components for use new mask handlers. +- Adding datetime and cnpj masks. +- [Breaking Change] Refactoring MaskService. +- Separate mask handlers for better extensibility. +- Adding tests for all mask handlers. +- Refactoring Components for use new mask handlers. ## 0.3.6 -* Fix vanilla-mask path on windows. \ No newline at end of file +- Fix vanilla-mask path on windows. diff --git a/README.md b/README.md index 428a55b6..428d9efd 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ [![Help Contribute to Open Source](https://www.codetriage.com/benhurott/react-native-masked-text/badges/users.svg)](https://www.codetriage.com/benhurott/react-native-masked-text) -This is a simple masked text (normal text and input text) component for React-Native. +![logo](docs/res/logo.png) -Thanks to [vanilla-masker](https://github.com/BankFacil/vanilla-masker) =). -Thanks to [moment](http://momentjs.com/) =). +This is a simple masked text (normal text and input text) component for React-Native. ## Supported Versions @@ -28,7 +27,7 @@ export default class MyComponent extends Component { super(props) } - isValid() { + 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. @@ -183,9 +182,9 @@ const styles = StyleSheet.create({ You can use the native props of TextInput, with this in mind: -* onChangeText is intercepted by component. -* value is intercepted by component. -* if you pass keyboardType, it will override the keyboardType of masked component. +- onChangeText is intercepted by component. +- value is intercepted by component. +- if you pass keyboardType, it will override the keyboardType of masked component. #### TextInput Methods @@ -193,31 +192,31 @@ If you want to use the methods of the native TextInput, use the `getElement()` m ```jsx export default class App extends React.Component { - onGoFocus() { - // when you call getElement method, the instance of native TextInput will returned. - this.refs['myText'].getElement().focus() - } + onGoFocus() { + // when you call getElement method, the instance of native TextInput will returned. + this._myTextInputMask.getElement().focus() + } - render() { - return ( - - - - - -