/
index.js
46 lines (41 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import { Provider } from 'react-redux';
import { createStore, combineReducers } from 'redux';
import { storiesOf, addDecorator } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { reducer as formReducer } from 'redux-form';
import SchemaVis from 'react-jsonschema-vis';
import { ReduxTestForm } from './TestForm';
import components from '../src';
import * as arrayFieldSchemas from './arrayFieldSchemas';
import simpleFormSchema from './schema.json';
const rootReducers = combineReducers({ form: formReducer });
const store = createStore(
rootReducers,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
addDecorator(getStory => (
<Provider store={store}>
{getStory()}
</Provider>
));
const storybook = storiesOf('Reactstrap Redux-Form Jsonschema Vis', module);
storybook.add('simple form', () => (
<ReduxTestForm
form="simple form"
onSubmit={data => action('Form(SimpleForm) submit')(data)}
>
<SchemaVis
form="simple form"
schema={simpleFormSchema}
components={components}
/>
</ReduxTestForm>
));
Object.values(arrayFieldSchemas).forEach(schema => {
storybook.add(schema.title, () => (
<ReduxTestForm form={schema.id} onSubmit={data => action(`Form(${schema.id}) submit`)(data)}>
<SchemaVis form={schema.id} schema={schema} components={components} />
</ReduxTestForm>
));
});