diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4680fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,76 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +# Watchman +.watchmanconfig \ No newline at end of file diff --git a/README.md b/README.md index d5a7512..bf47844 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ export class FormView extends React.Component{ } render(){ - return ( + return (
{ + render () { + let wrappedChildren = [] + React.Children.map(this.props.children, (child, i) => { if (!child) { - return; + return + } + wrappedChildren.push(React.cloneElement(child, { + key: child.ref || child.type + i, + fieldRef: child.ref, + ref: child.ref, + onFocus: this.handleFieldFocused.bind(this), + onChange: this.handleFieldChange.bind(this, child.ref) } - wrappedChildren.push(React.cloneElement(child, { - key: child.ref || child.type+i, - fieldRef : child.ref, - ref: child.ref, - onFocus:this.handleFieldFocused.bind(this), - onChange:this.handleFieldChange.bind(this, child.ref) - } - )); - }, this); + )) + }, this) return ( - {wrappedChildren} + {this.props.label} + {wrappedChildren} - ); + ) } } diff --git a/src/fields/Separator.js b/src/fields/Separator.js index 1b77bcf..53de1a5 100644 --- a/src/fields/Separator.js +++ b/src/fields/Separator.js @@ -1,7 +1,7 @@ 'use strict'; import React from 'react'; -let { View, StyleSheet, Text} = require('react-native'); +let { View, ViewPropTypes, StyleSheet, Text} = require('react-native'); export class Separator extends React.Component{ render(){ @@ -18,7 +18,7 @@ export class Separator extends React.Component{ Separator.propTypes = { labelStyle: Text.propTypes.style, - containerStyle: View.propTypes.style + containerStyle: ViewPropTypes.style } diff --git a/src/index.js b/src/index.js index ff3940c..e5fd97c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ - +// comment here if you have apln import {InputField} from './src/fields/InputField'; import {SwitchField} from './src/fields/SwitchField'; diff --git a/src/lib/InputComponent.js b/src/lib/InputComponent.js index 4f65d8f..0448697 100644 --- a/src/lib/InputComponent.js +++ b/src/lib/InputComponent.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import ReactNative, { Platform } from 'react-native'; import {Field} from './Field.js'; -const {View, StyleSheet, TextInput, Text} = ReactNative; +const {View, ViewPropTypes, StyleSheet, TextInput, Text} = ReactNative; function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; @@ -208,5 +208,5 @@ export class InputComponent extends React.Component{ InputComponent.propTypes = { labelStyle: Text.propTypes.style, inputStyle: TextInput.propTypes.style, - containerStyle: View.propTypes.style + containerStyle: ViewPropTypes.style } diff --git a/src/lib/LinkComponent.js b/src/lib/LinkComponent.js index c2c0d23..f4a2fea 100644 --- a/src/lib/LinkComponent.js +++ b/src/lib/LinkComponent.js @@ -1,7 +1,7 @@ 'use strict'; import React from 'react'; -let { View, StyleSheet, Text} = require('react-native'); +let { View, ViewPropTypes, StyleSheet, Text} = require('react-native'); import {Field} from './Field'; @@ -48,5 +48,5 @@ export class LinkComponent extends React.Component{ LinkComponent.propTypes = { labelStyle: Text.propTypes.style, - containerStyle: View.propTypes.style + containerStyle: ViewPropTypes.style } diff --git a/src/lib/SwitchComponent.js b/src/lib/SwitchComponent.js index 80f978f..083e178 100644 --- a/src/lib/SwitchComponent.js +++ b/src/lib/SwitchComponent.js @@ -1,7 +1,7 @@ 'use strict'; import React from 'react'; -let { View, StyleSheet, Text, Switch} = require('react-native'); +let { View, ViewPropTypes, StyleSheet, Text, Switch} = require('react-native'); import {Field} from './Field'; @@ -53,7 +53,7 @@ export class SwitchComponent extends React.Component{ SwitchComponent.propTypes = { labelStyle: Text.propTypes.style, - containerStyle: View.propTypes.style, + containerStyle: ViewPropTypes.style, switchStyle: Switch.propTypes.style }