react-native-formik
Advanced tools
+1
-1
@@ -8,3 +8,3 @@ language: node_js | ||
| node_js: | ||
| - '9' | ||
| - "10" | ||
| after_success: | ||
@@ -11,0 +11,0 @@ - npm run travis-deploy-once "npm run coveralls && npm run semantic-release" |
+4
-1
@@ -60,3 +60,6 @@ import * as React from 'react'; | ||
| export function withNextInputAutoFocusForm<Props>( | ||
| WrappedComponent: React.ComponentType<Props> | ||
| WrappedComponent: React.ComponentType<Props>, | ||
| options?: { | ||
| submitAfterLastInput: Boolean | ||
| } | ||
| ): React.ComponentClass<Props>; | ||
@@ -63,0 +66,0 @@ |
+3
-0
@@ -5,2 +5,5 @@ const path = require("path"); | ||
| preset: "react-native", | ||
| transform: { | ||
| "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js" | ||
| }, | ||
| transformIgnorePatterns: [ | ||
@@ -7,0 +10,0 @@ "node_modules/(?!(react-native|react-native-button|react-native-core-library|@bam.tech/[w-]*|static-container|react-native-tab-view)|react-native-iphone-x-helper/)" |
+4
-1
@@ -11,5 +11,8 @@ import Enzyme from "enzyme"; | ||
| const { document } = new JSDOM("").window; | ||
| const { window } = new JSDOM(""); | ||
| const { document } = window; | ||
| global.document = document; | ||
| global.window = window; | ||
| }; | ||
| mockDocumentForEnzymeMount(); |
+13
-14
| { | ||
| "name": "react-native-formik", | ||
| "version": "1.7.4", | ||
| "version": "1.7.5", | ||
| "description": "Make the most of your React Native forms with Formik", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
| "react-native-root-siblings": "3.1.7", | ||
| "recompose": "^0.26.0" | ||
| "recompose": "^0.30.0" | ||
| }, | ||
@@ -39,7 +39,6 @@ "author": "Almouro <contact@almouro.com> (http://alexandremoureaux.com/)", | ||
| "@babel/runtime": "^7.2.0", | ||
| "@types/react": "^16.3.8", | ||
| "babel-core": "6.26.0", | ||
| "babel-jest": "23.6.0", | ||
| "babel-preset-react-native": "4.0.0", | ||
| "commitizen": "^2.9.6", | ||
| "@types/react": "^16.8.6", | ||
| "babel-jest": "24.3.1", | ||
| "babel-preset-react-native": "5.0.2", | ||
| "commitizen": "^3.0.7", | ||
| "coveralls": "^3.0.0", | ||
@@ -49,12 +48,12 @@ "cz-conventional-changelog": "^2.1.0", | ||
| "enzyme-adapter-react-16": "^1.0.0", | ||
| "eslint": "^5.2.0", | ||
| "eslint": "^5.15.1", | ||
| "eslint-config-bambi": "^1.4.0", | ||
| "formik": "^1.0.2", | ||
| "husky": "^0.14.3", | ||
| "jest": "23.6.0", | ||
| "metro-react-native-babel-preset": "0.50.0", | ||
| "husky": "^1.3.1", | ||
| "jest": "24.3.1", | ||
| "metro-react-native-babel-preset": "0.53.0", | ||
| "prettier": "^1.14.0", | ||
| "react": "16.2.0", | ||
| "react-dom": "16.2.1", | ||
| "react-native": "0.53.0", | ||
| "react": "16.8.4", | ||
| "react-dom": "16.8.4", | ||
| "react-native": "0.58.6", | ||
| "semantic-release": "^15.9.3", | ||
@@ -61,0 +60,0 @@ "travis-deploy-once": "^5.0.1", |
+18
-18
@@ -52,15 +52,10 @@ # React Native Formik [](https://coveralls.io/github/bamlab/react-native-formik?branch=master) [](https://opensource.org/licenses/MIT) [](https://github.com/semantic-release/semantic-release) [](https://www.npmjs.com/package/react-native-formik) [](https://www.npmjs.com/package/react-native-formik) | ||
| ### The Gist | ||
| ### The Gist [See it in Snack](https://snack.expo.io/@almouro/react-native-formik-gist) | ||
| Say we want to create a form with Material design inputs. | ||
| #### Use any Input component | ||
| Let's create our custom text input design, called `MaterialTextInput`: | ||
| We can use any `Input` component. It will receive an `error` prop in addition to the usual `TextInput` props. | ||
| We can use [react-native-material-textfield](https://github.com/n4kz/react-native-material-textfield) for the material design. | ||
| For instance, we can use [react-native-material-textfield](https://github.com/n4kz/react-native-material-textfield) for the material design. | ||
| Our component will receive `error` in addition to the usual `TextInput` props. | ||
| For `withNextInputAutoFocus` to work, the input component should be a class and implement a `focus` method. | ||
| #### Create our form logic | ||
@@ -71,7 +66,11 @@ | ||
| - automatically manage its state in formik provided it has a `name` prop | ||
| - automatically set its error prop if input is touched or form has been submitted | ||
| - automatically | ||
| - automatically set its `error` prop if input is touched or form has been submitted | ||
| - automatically adds the correct `TextInput` props dependending on its type (at the moment, `email`, `password`, `digits`, `name` are supported) | ||
| Let's add in `withNextInputAutoFocusInput`: | ||
| Let's add in `withNextInputAutoFocusInput`, which provides those awesome features: | ||
| - when an input is submitted, it will automatically focuses on the next or submit the form if it's the last one | ||
| - sets return key to "next" or "done" if input is the last one or not | ||
| For `withNextInputAutoFocus` to work, the input component should be a class and implement a `focus` method. | ||
| ```javascript | ||
@@ -83,3 +82,3 @@ import { compose } from "recompose"; | ||
| } from "react-native-formik"; | ||
| import MaterialTextInput from "./MaterialTextInput"; | ||
| import { TextField } from "react-native-material-textfield"; | ||
@@ -89,3 +88,3 @@ const MyInput = compose( | ||
| withNextInputAutoFocusInput | ||
| )(MaterialTextInput); | ||
| )(TextField); | ||
| ``` | ||
@@ -147,12 +146,13 @@ | ||
| import * as Yup from "yup"; | ||
| import makeInputGreatAgain, { | ||
| import { | ||
| handleTextInput, | ||
| withNextInputAutoFocusForm, | ||
| withNextInputAutoFocusInput | ||
| } from "react-native-formik"; | ||
| import MaterialTextInput from "./MaterialTextInput"; | ||
| import { TextField } from "react-native-material-textfield"; | ||
| const MyInput = compose( | ||
| makeInputGreatAgain, | ||
| handleTextInput, | ||
| withNextInputAutoFocusInput | ||
| )(MaterialTextInput); | ||
| )(TextField); | ||
| const Form = withNextInputAutoFocusForm(View); | ||
@@ -190,3 +190,3 @@ | ||
| ### Custom components | ||
| ### Custom components [See it in Snack](https://snack.expo.io/@almouro/react-native-formik-gist) | ||
@@ -193,0 +193,0 @@ #### withFormikControl usage |
Sorry, the diff of this file is too big to display
22
-4.35%651
1.24%2466886
-0.89%+ Added
+ Added
+ Added
- Removed
Updated