Skip to content

Commit

Permalink
chore: start trying a refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois authored and jsomsanith committed May 9, 2017
1 parent c199f5d commit 9013edc
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 27 deletions.
6 changes: 5 additions & 1 deletion packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@
},
"dependencies": {
"classnames": "^2.2.5",
"json-schema-form-core": "^1.0.0-alpha.2",
"keycode": "^2.1.8",
"react-autowhatever": "^7.0.0",
"react-jsonschema-form": "^0.42.0"
"react-jsonschema-form": "^0.42.0",
"react-redux": "^5.0.4",
"redux-form": "^6.6.3",
"tv4": "^1.3.0"
},
"peerDependencies": {
"react": "^15.4.0",
Expand Down
48 changes: 48 additions & 0 deletions packages/forms/src/UIForm/UIForm.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { PropTypes } from 'react';
import { Field, reduxForm } from 'redux-form';

import {
schemaDefaults,
jsonref,
merge,
traverseSchema,
traverseForm,
} from 'json-schema-form-core';

class UIForm extends React.Component {

render() {
const { jsonSchema, uiSchema, properties } = this.props.data || {};
debugger;
schemaDefaults;
jsonref;
merge;
traverseSchema;
traverseForm;
return (
<form onSubmit={this.props.handleSubmit}>
<div>
<label htmlFor="firstName">First Name</label>
<Field name="firstName" component="input" type="text" />
</div>
<div>
<label htmlFor="lastName">Last Name</label>
<Field name="lastName" component="input" type="text" />
</div>
<div>
<label htmlFor="email">Email</label>
<Field name="email" component="input" type="email" />
</div>
<button type="submit">Submit</button>
</form>
);
}
}

UIForm.propTypes = {
handleSubmit: PropTypes.func.isRequired,
};

export default reduxForm({
form: 'form' // a unique name for this form
})(UIForm);
13 changes: 13 additions & 0 deletions packages/forms/src/UIForm/UIForm.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';

import UIForm from './UIForm.component';

describe('UIForm', () => {
it('should render', () => {
const wrapper = shallow(
<UIForm />
);
expect(wrapper).toMatchSnapshot();
});
});
3 changes: 3 additions & 0 deletions packages/forms/src/UIForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UIForm from './UIForm.component';

export default UIForm;
36 changes: 25 additions & 11 deletions packages/forms/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
import React from 'react';
import ReactDOM from 'react-dom';
import a11y from 'react-a11y';

import { Provider } from 'react-redux';
import { storiesOf, action } from '@kadira/storybook';
import { withKnobs, object } from '@kadira/storybook-addon-knobs';

import Well from 'react-bootstrap/lib/Well';
import IconsProvider from 'react-talend-components/lib/IconsProvider';

import Form from '../src/Form';

import { createStore, combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';

const reducers = {
// ... your other reducers here ...
form: formReducer, // <---- Mounted at 'form'
};

const reducer = combineReducers(reducers);
const store = createStore(reducer);

import Form from '../src/UIForm';

a11y(ReactDOM);

const decoratedStories = storiesOf('Form', module)
.addDecorator(withKnobs)
.addDecorator(story => (
<div className="container-fluid">
<div
className="col-md-offset-1 col-md-10"
style={{ marginTop: '20px', marginBottom: '20px' }}
>
<Well>
{story()}
</Well>
<Provider store={store}>
<div className="container-fluid">
<div
className="col-md-offset-1 col-md-10"
style={{ marginTop: '20px', marginBottom: '20px' }}
>
<Well>
{story()}
</Well>
</div>
</div>
</div>
</Provider>
));

const capitalizeFirstLetter =
Expand Down
84 changes: 69 additions & 15 deletions packages/forms/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,9 @@ bootstrap-sass@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz#6596c7ab40f6637393323ab0bc80d064fc630498"

bootstrap-talend-theme@^0.71.0:
version "0.71.0"
resolved "https://registry.yarnpkg.com/bootstrap-talend-theme/-/bootstrap-talend-theme-0.71.0.tgz#b6946f3d5f9742cbefd7f71d3542c341c887ec7f"
bootstrap-talend-theme@^0.72.2:
version "0.72.2"
resolved "https://registry.yarnpkg.com/bootstrap-talend-theme/-/bootstrap-talend-theme-0.72.2.tgz#d164a2d5cc39538b40bf3918b9e0738184ae9a0b"
dependencies:
bootstrap-sass "^3.3.7"

Expand Down Expand Up @@ -1692,6 +1692,13 @@ cpx@^1.5.0:
shell-quote "^1.6.1"
subarg "^1.0.0"

create-react-class@^15.5.1:
version "15.5.2"
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.2.tgz#6a8758348df660b88326a0e764d569f274aad681"
dependencies:
fbjs "^0.8.9"
object-assign "^4.1.1"

cross-spawn@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
Expand Down Expand Up @@ -2101,6 +2108,10 @@ es5-shim@^4.5.9:
version "4.5.9"
resolved "https://registry.yarnpkg.com/es5-shim/-/es5-shim-4.5.9.tgz#2a1e2b9e583ff5fed0c20a3ee2cbf3f75230a5c0"

es6-error@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"

es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512"
Expand Down Expand Up @@ -2469,7 +2480,7 @@ fb-watchman@^2.0.0:
dependencies:
bser "^2.0.0"

fbjs@^0.8.1, fbjs@^0.8.4:
fbjs@^0.8.1, fbjs@^0.8.4, fbjs@^0.8.9:
version "0.8.12"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
dependencies:
Expand Down Expand Up @@ -2861,7 +2872,7 @@ [email protected]:
version "2.16.3"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"

[email protected], hoist-non-react-statics@^1.2.0:
[email protected], hoist-non-react-statics@^1.0.3, hoist-non-react-statics@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"

Expand Down Expand Up @@ -3013,7 +3024,7 @@ interpret@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.2.tgz#f4f623f0bb7122f15f5717c8e254b8161b5c5b2d"

[email protected], invariant@^2.1.0, invariant@^2.2.0, invariant@^2.2.1:
[email protected], invariant@^2.0.0, invariant@^2.1.0, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies:
Expand Down Expand Up @@ -3156,6 +3167,10 @@ is-primitive@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"

is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"

is-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"
Expand Down Expand Up @@ -3749,6 +3764,10 @@ json-loader@^0.5.4:
version "0.5.4"
resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de"

json-schema-form-core@^1.0.0-alpha.2:
version "1.0.0-alpha.2"
resolved "https://registry.yarnpkg.com/json-schema-form-core/-/json-schema-form-core-1.0.0-alpha.2.tgz#60566287e5f3fb8d2ccb1337dca5d3b80c3391c9"

[email protected]:
version "0.2.3"
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
Expand Down Expand Up @@ -3871,7 +3890,7 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash-es@^4.2.1:
lodash-es@^4.17.3, lodash-es@^4.2.0, lodash-es@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"

Expand Down Expand Up @@ -4068,7 +4087,7 @@ lodash.uniq@^4.3.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"

[email protected], lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0:
[email protected], lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand Down Expand Up @@ -4500,7 +4519,7 @@ object-assign@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2"

object-assign@^4.0.1, object-assign@^4.1.0:
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

Expand Down Expand Up @@ -5057,6 +5076,12 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.0.0, prop-types@^15.5.6:
version "15.5.8"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.8.tgz#6b7b2e141083be38c8595aa51fc55775c7199394"
dependencies:
fbjs "^0.8.9"

proxy-addr@~1.1.3:
version "1.1.4"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3"
Expand Down Expand Up @@ -5283,6 +5308,18 @@ react-prop-types@^0.4.0:
dependencies:
warning "^3.0.0"

react-redux@^5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.4.tgz#1563babadcfb2672f57f9ceaa439fb16bf85d55b"
dependencies:
create-react-class "^15.5.1"
hoist-non-react-statics "^1.0.3"
invariant "^2.0.0"
lodash "^4.2.0"
lodash-es "^4.2.0"
loose-envify "^1.1.0"
prop-types "^15.0.0"

react-simple-di@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/react-simple-di/-/react-simple-di-1.2.0.tgz#dde0e5bf689f391ef2ab02c9043b213fe239c6d0"
Expand All @@ -5296,9 +5333,9 @@ react-stubber@^1.0.0:
dependencies:
babel-runtime "^6.5.0"

react-talend-components@^0.71.0:
version "0.71.0"
resolved "https://registry.yarnpkg.com/react-talend-components/-/react-talend-components-0.71.0.tgz#dec2f1d5c14669e89460a1dbf56821124d340f9b"
react-talend-components@^0.72.2:
version "0.72.2"
resolved "https://registry.yarnpkg.com/react-talend-components/-/react-talend-components-0.72.2.tgz#9426e165996359ecc82697ce1083157804e98cb1"
dependencies:
lodash "^4.17.4"
react-autowhatever "^7.0.0"
Expand Down Expand Up @@ -5428,6 +5465,19 @@ reduce-function-call@^1.0.1:
dependencies:
balanced-match "^0.4.2"

redux-form@^6.6.3:
version "6.6.3"
resolved "https://registry.yarnpkg.com/redux-form/-/redux-form-6.6.3.tgz#62362654f2214c83a8f9fcb8313702bb46f92205"
dependencies:
deep-equal "^1.0.1"
es6-error "^4.0.0"
hoist-non-react-statics "^1.2.0"
invariant "^2.2.2"
is-promise "^2.1.0"
lodash "^4.17.3"
lodash-es "^4.17.3"
prop-types "^15.5.6"

redux@^3.5.2:
version "3.6.0"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.6.0.tgz#887c2b3d0b9bd86eca2be70571c27654c19e188d"
Expand Down Expand Up @@ -6011,9 +6061,9 @@ table@^3.7.8:
slice-ansi "0.0.4"
string-width "^2.0.0"

talend-icons@^0.71.0:
version "0.71.0"
resolved "https://registry.yarnpkg.com/talend-icons/-/talend-icons-0.71.0.tgz#d52c632180d35385a6ae382dfb59e7f56ccb9ac2"
talend-icons@^0.72.2:
version "0.72.2"
resolved "https://registry.yarnpkg.com/talend-icons/-/talend-icons-0.72.2.tgz#4bdabf0091695c6ede2ecdb218c4fb0cb66b8da9"

tapable@^0.1.8, tapable@~0.1.8:
version "0.1.10"
Expand Down Expand Up @@ -6126,6 +6176,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

tv4@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/tv4/-/tv4-1.3.0.tgz#d020c846fadd50c855abb25ebaecc68fc10f7963"

tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
Expand Down

0 comments on commit 9013edc

Please sign in to comment.