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:
parent
22dd961fce
commit
51fd97ec7c
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
};
|
30
spikes/form/redux-form/client/form/redux-form-proxy.js
Normal file
30
spikes/form/redux-form/client/form/redux-form-proxy.js
Normal 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} />
|
||||
)
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user