1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-10 21:30:06 +02:00

Update redux form proxy and Input to include Proxy functionality in Input component

This commit is contained in:
JUDIT GRESKOVITS 2017-01-06 15:17:08 +00:00
parent 22dd961fce
commit 51fd97ec7c
5 changed files with 34 additions and 35 deletions

View File

@ -2,17 +2,10 @@ const React = require('react');
const ReactRouter = require('react-router');
const ReduxForm = require('redux-form');
const Styled = require('styled-components');
// const Input = require('./input');
// const InputRfProps = require('./inputRfProps');
const Input = require('./input');
const validate = require('./validate');
const Form = require('./shared').form;
const proxy = require('./proxy');
const {
Input
} = proxy;
const {
browserHistory
} = ReactRouter;

View File

@ -1,17 +1,11 @@
const React = require('react');
const ReduxForm = require('redux-form');
const Styled = require('styled-components');
// const Input = require('./input');
const Input = require('./input');
const InputRfProps = require('./inputRfProps');
const validate = require('./validate');
const Form = require('./shared').form;
const proxy = require('./proxy');
const {
Input
} = proxy;
const {
Field,
reduxForm

View File

@ -1,5 +1,6 @@
const React = require('react');
const Styled = require('styled-components');
const Proxy = require('./redux-form-proxy');
const {
default: styled
@ -130,4 +131,4 @@ Input.propTypes = {
value: React.PropTypes.string
};
module.exports = Input;
module.exports = Proxy(Input);

View File

@ -1,19 +0,0 @@
const transformPropsWith = require('transform-props-with');
const Input = require('./input');
const {
default: tx
} = transformPropsWith;
const flattenProps = props => {
const { input, meta, ...rest } = props;
return {
...input,
...meta,
...rest
};
}
module.exports = {
Input: tx(flattenProps)(Input)
};

View File

@ -0,0 +1,30 @@
const React = require('react');
const transformPropsWith = require('transform-props-with');
const {
default: tx
} = transformPropsWith;
const Proxy = tx(props => {
const { input, meta, ...rest } = props;
return {
...input,
...meta,
...rest
};
});
const isReduxForm = (props) =>
props.hasOwnProperty('input') || props.hasOwnProperty('meta');
module.exports = (Component) => {
const ProxiedComponent = Proxy(Component);
return (props) => {
return isReduxForm(props) ? (
<ProxiedComponent {...props} />
) : (
<Component {...props} />
)
}
};