Skip to content

Commit a814d1f

Browse files
committed
Added wizard.js
1 parent 54cb9ea commit a814d1f

File tree

17 files changed

+2568
-1303
lines changed

17 files changed

+2568
-1303
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Data Driven Forms is a React library used for rendering and managing forms with
1515

1616
:tada: Features :tada:
1717
- Easily readable schema, you don't need to know any HTML or JS to be able to write your own form schemas!
18-
- You can use your own components or use one of our provided mappers ([PatternFly 3](https://patternfly-react.surge.sh/patternfly-3/index.html), [PatternFly 4](https://patternfly-react.surge.sh/patternfly-4/) or [Material-UI](https://material-ui.com/)!)
18+
- You can use your own components or use one of our provided mappers ([PatternFly 3](https://patternfly-react.surge.sh/patternfly-3/index.html), [PatternFly 4](https://patternfly-react.surge.sh/patternfly-4/), [Material-UI](https://material-ui.com/) or [Ant Design](https://ant.design/)!)
1919
- Form state managing out-of-the-box (including error states!)
2020
- Fully customizable (you can use your own buttons, actions, etc.)!
2121
- Conditional fields!
@@ -36,8 +36,13 @@ Data Driven Forms is a React library used for rendering and managing forms with
3636
- [Material-UI Mapper](#material-ui-mapper)
3737
- [PatternFly 3 Mapper](#patternfly-3-mapper)
3838
- [PatternFly 4 Mapper](#patternfly-4-mapper)
39+
<<<<<<< HEAD
3940
- [BlueprintJS Mapper](#blueprintjs-mapper)
4041
- [Semantic UI Mapper](#semantic-ui-mapper)
42+
=======
43+
- [Material-UI Mapper](#material-ui-mapper)
44+
- [Ant Design Mapper](#ant-design-mapper)
45+
>>>>>>> Added wizard.js
4146
- [Usage](#usage)
4247
- [Custom mapper](#custom-mapper)
4348
- [Basic provided components](#basic-provided-components)
@@ -107,6 +112,7 @@ $ npm install @data-driven-forms/blueprint-component-mapper -S
107112
$ yarn add @data-driven-forms/blueprint-component-mapper
108113
```
109114

115+
<<<<<<< HEAD
110116
#### [Semantic UI Mapper](https://data-driven-forms.org/mappers/suir-component-mapper)
111117

112118
```console
@@ -119,6 +125,18 @@ $ yarn add @data-driven-forms/suir-component-mapper
119125

120126
Component libraries in mappers are external dependencies. Make sure to install them in your bundles.
121127

128+
=======
129+
#### [Ant Design Mapper](https://www.npmjs.com/package/@data-driven-forms/ant-component-mapper)
130+
131+
```console
132+
$ npm install @data-driven-forms/ant-component-mapper -S
133+
```
134+
135+
```console
136+
$ yarn add @data-driven-forms/ant-component-mapper
137+
```
138+
139+
>>>>>>> Added wizard.js
122140
### Usage
123141

124142
In order to Data Driven Forms in your component you need the renderer and a component mapper, which provides component mapper and form template.
@@ -215,11 +233,13 @@ Please use our [documentation site](https://data-driven-forms.org/). In case of
215233
- [PatternFly 3 Design documentation](https://www.patternfly.org/v3/)
216234
- [PatternFly 4 Design documentation](https://www.patternfly.org/v4/)
217235
- [Material-UI documentation](https://material-ui.com/)
236+
- [Ant Design documentation](https://ant.design/)
218237
- NPM
219238
- [React Form Renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer)
220239
- [PatternFly 3 Mapper](https://www.npmjs.com/package/@data-driven-forms/pf3-component-mapper)
221240
- [PatternFly 4 Mapper](https://www.npmjs.com/package/@data-driven-forms/pf4-component-mapper)
222241
- [MaterialUI Mapper](https://www.npmjs.com/package/@data-driven-forms/mui-component-mapper)
242+
- [Ant Design Mapper](https://www.npmjs.com/package/@data-driven-forms/ant-component-mapper)
223243
- Examples of schemas (PatternFly 3)
224244
- [ManageIQ Form Components](https://github.com/ManageIQ/manageiq-ui-classic/tree/master/app/javascript/components)
225245

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { componentTypes, validatorTypes } from '@data-driven-forms/react-form-renderer';
2+
3+
const wizardSchema = {
4+
fields: [
5+
{
6+
component: componentTypes.WIZARD,
7+
name: 'wizzard',
8+
buttonLabels: {},
9+
title: 'Cokoliv',
10+
stepsInfo: [{ title: 'Add a source' }, { title: 'Configure a source' }, { title: 'Summary' }],
11+
fields: [
12+
{
13+
title: 'Get started with adding source',
14+
name: 'step-1',
15+
nextStep: {
16+
when: 'source-type',
17+
stepMapper: {
18+
aws: 'aws',
19+
google: 'google'
20+
}
21+
},
22+
fields: [
23+
{
24+
component: componentTypes.TEXTAREA,
25+
name: 'source-name',
26+
type: 'text',
27+
label: 'Source name'
28+
},
29+
{
30+
component: componentTypes.SELECT,
31+
name: 'source-type',
32+
label: 'Source type',
33+
isRequired: true,
34+
options: [
35+
{
36+
label: 'Please Choose'
37+
},
38+
{
39+
value: 'aws',
40+
label: 'Aws'
41+
},
42+
{
43+
value: 'google',
44+
label: 'Google'
45+
}
46+
],
47+
validate: [
48+
{
49+
type: validatorTypes.REQUIRED
50+
}
51+
]
52+
}
53+
]
54+
},
55+
{
56+
title: 'Configure AWS',
57+
name: 'aws',
58+
nextStep: 'summary',
59+
fields: [
60+
{
61+
component: componentTypes.TEXT_FIELD,
62+
name: 'aws-field',
63+
label: 'Aws field part'
64+
}
65+
]
66+
},
67+
{
68+
name: 'google',
69+
title: 'Configure google',
70+
nextStep: 'summary',
71+
fields: [
72+
{
73+
component: componentTypes.TEXT_FIELD,
74+
name: 'google-field',
75+
label: 'Google field part'
76+
}
77+
]
78+
},
79+
{
80+
title: 'hola title',
81+
name: 'holaname',
82+
component: componentTypes.PLAIN_TEXT,
83+
label: 'Hello this is a test and this shall be a text'
84+
},
85+
{
86+
nextStep: 'holaname',
87+
fields: [
88+
{
89+
name: 'summary',
90+
component: componentTypes.PLAIN_TEXT,
91+
isDisabled: true,
92+
label: 'Summary'
93+
}
94+
],
95+
name: 'summary'
96+
}
97+
]
98+
}
99+
]
100+
};
101+
102+
export default wizardSchema;
Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
/* eslint-disable */
2-
import React from 'react';
2+
import React, { useState } from 'react';
33
import ReactDOM from 'react-dom';
44
import FormRenderer from '@data-driven-forms/react-form-renderer';
55
import 'antd/dist/antd.css';
66
import './style.css';
7-
import { componentMapper, FormTemplate } from '../src';
8-
9-
//import { RedditOutlined } from '@ant-design/icons';
10-
//import { Button, Input, Form, Checkbox } from 'antd';
117
import demoSchema from '@data-driven-forms/common/src/demoschema';
8+
import { componentMapper, FormTemplate } from '../src';
9+
import wizardSchema from './demo-schemas/wizard-schema';
10+
11+
12+
13+
const style = {
14+
position: 'relative',
15+
width:'70%',
16+
margin:'auto'
17+
}
1218

13-
const App = () => (
14-
<FormRenderer
15-
componentMapper={componentMapper}
16-
FormTemplate={props => <FormTemplate {...props} />}
17-
onSubmit={console.log}
18-
schema={demoSchema}
19-
/>
20-
)
19+
const App = () => (
20+
<div style={style}>
21+
<FormRenderer
22+
componentMapper={componentMapper}
23+
FormTemplate={(props) => <FormTemplate {...props} />}
24+
onSubmit={console.log}
25+
schema={demoSchema}
26+
/>
27+
</div>
28+
);
2129

2230
ReactDOM.render(<App />, document.getElementById('root'));

packages/ant-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@data-driven-forms/react-form-renderer": "*",
2323
"@semantic-release/git": "^7.0.5",
2424
"@semantic-release/npm": "^5.1.1",
25-
"antd": "^4.0.1",
25+
"antd": "^4.2.0",
2626
"babel-core": "^7.0.0-bridge.0",
2727
"babel-eslint": "9.x",
2828
"babel-jest": "^23.6.0",

packages/ant-component-mapper/src/common/form-wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const AntForm = ({ label, children, layout, component, invalid, isRequired, help
1818
label={label}
1919
name={label}
2020
>
21-
{children}
21+
<div>{children}</div>
2222
</Form.Item>
2323
</Form>
2424
);

packages/ant-component-mapper/src/files/checkbox.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ export const SingleCheckbox = (props) => {
1717
const text = invalid || helperText || description;
1818
return (
1919
<AntForm component="fieldset" invalid={invalid} help={text}>
20-
<AntCheckbox checked={input.checked} {...input} disabled={isDisabled || isReadOnly} value={input.name}>
20+
<AntCheckbox
21+
checked={input.checked}
22+
{...input}
23+
defaultValue={input.value ? input.value : undefined}
24+
disabled={isDisabled || isReadOnly}
25+
value={input.name}
26+
>
2127
{isRequired ? <IsRequired>{label}</IsRequired> : label}
2228
</AntCheckbox>
2329
</AntForm>

packages/ant-component-mapper/src/files/component-mapper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TimePicker from './time-picker';
99
import Radio from './radio';
1010
import Switch from './switch';
1111
import Select from './select';
12+
import Wizard from './wizard';
1213
import SubForm from './sub-form.js';
1314
export const components = {
1415
TextField,
@@ -20,7 +21,8 @@ export const components = {
2021
DatePicker,
2122
TimePicker,
2223
PlainText,
23-
SubForm
24+
SubForm,
25+
Wizard
2426
};
2527

2628
const componentMapper = {
@@ -34,7 +36,8 @@ const componentMapper = {
3436
[componentTypes.DATE_PICKER]: DatePicker,
3537
[componentTypes.TIME_PICKER]: TimePicker,
3638
[componentTypes.PLAIN_TEXT]: PlainText,
37-
[componentTypes.SWITCH]: Switch
39+
[componentTypes.SWITCH]: Switch,
40+
[componentTypes.WIZARD]: Wizard
3841
};
3942

4043
export default componentMapper;

packages/ant-component-mapper/src/files/date-picker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const DatePicker = (props) => {
1515
<AntForm layout="vertical" isRequired={isRequired} label={label} invalid={invalid} help={help}>
1616
<AntDatePicker
1717
disabled={isDisabled || isReadOnly}
18+
defaultValue={input.value ? input.value : undefined}
1819
placeholder={placeholderDisplay}
1920
required={isRequired}
2021
error={!!invalid}

packages/ant-component-mapper/src/files/select.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const Select = (props) => {
3232
return (
3333
<AntForm layout="vertical" label={label} isRequired={isRequired} invalid={invalid} help={invalid || helperText || description}>
3434
<AntSelect
35-
placeholder={placeholder || 'Please choose'}
36-
// value={options.filter(({ value }) => (rest.isMulti ? input.value.includes(value) : value === input.value))}
3735
{...input}
36+
defaultValue={input.value ? input.value : undefined}
37+
placeholder={placeholder || 'Please choose'}
3838
mode={rest.isMulti ? 'tags' : ''}
3939
showSearch={!!isSearchable}
4040
filterOption={(input, option) => option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}

packages/ant-component-mapper/src/files/switch.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ export const Switch = (props) => {
1616
const { name, value, onChange, onBlur } = input;
1717
return (
1818
<AntForm help={text} invalid={invalid} isRequired={isRequired} error={!!invalid} label={input.checked ? onText || label : offText || label}>
19-
<AntSwitch {...rest} onChange={onChange} value={value} name={name} onClick={onBlur} disabled={isDisabled || isReadOnly} />
19+
<AntSwitch
20+
{...rest}
21+
defaultValue={input.value ? input.value : undefined}
22+
onChange={onChange}
23+
value={value}
24+
name={name}
25+
onClick={onBlur}
26+
disabled={isDisabled || isReadOnly}
27+
/>
2028
</AntForm>
2129
);
2230
};

0 commit comments

Comments
 (0)