Skip to content

Commit ebb777e

Browse files
committed
Add wizard schema to MUI demo
1 parent 1cd8efc commit ebb777e

File tree

2 files changed

+96
-2
lines changed

2 files changed

+96
-2
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
value: 'aws',
37+
label: 'Aws'
38+
},
39+
{
40+
value: 'google',
41+
label: 'Google'
42+
}
43+
],
44+
validate: [
45+
{
46+
type: validatorTypes.REQUIRED
47+
}
48+
]
49+
}
50+
]
51+
},
52+
{
53+
title: 'Configure AWS',
54+
name: 'aws',
55+
nextStep: 'summary',
56+
fields: [
57+
{
58+
component: componentTypes.TEXT_FIELD,
59+
name: 'aws-field',
60+
label: 'Aws field part'
61+
}
62+
]
63+
},
64+
{
65+
name: 'google',
66+
title: 'Configure google',
67+
nextStep: 'summary',
68+
fields: [
69+
{
70+
component: componentTypes.TEXT_FIELD,
71+
name: 'google-field',
72+
label: 'Google field part'
73+
}
74+
]
75+
},
76+
{
77+
fields: [
78+
{
79+
name: 'summary',
80+
component: componentTypes.TEXT_FIELD,
81+
isDisabled: true,
82+
label: 'Summary'
83+
}
84+
],
85+
name: 'summary'
86+
}
87+
]
88+
}
89+
]
90+
};
91+
92+
export default wizardSchema;

packages/mui-component-mapper/demo/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import demoSchema from '@data-driven-forms/common/src/demoschema';
1111
import fieldArraySchema from './demo-schemas/field-array-schema';
1212

1313
import Button from '@material-ui/core/Button';
14+
import wizardSchema from './demo-schemas/wizard-schema';
1415

1516
const theme = createMuiTheme({
1617
typography: {
@@ -29,7 +30,7 @@ const compositeMapper = {
2930
};
3031

3132
const App = () => {
32-
const [schema, setSchema] = useState(fieldArraySchema);
33+
const [schema, setSchema] = useState(wizardSchema);
3334

3435
return (
3536
<ThemeProvider theme={theme}>
@@ -40,12 +41,13 @@ const App = () => {
4041
<Grid item xs={12}>
4142
<Button onClick={() => setSchema(demoSchema)}>Demo schema</Button>
4243
<Button onClick={() => setSchema(fieldArraySchema)}>Field array</Button>
44+
<Button onClick={() => setSchema(wizardSchema)}>Wizard</Button>
4345
</Grid>
4446
<Grid item xs={12}>
4547
<FormRenderer
4648
onSubmit={console.log}
4749
componentMapper={compositeMapper}
48-
FormTemplate={(props) => <FormTemplate {...props} />}
50+
FormTemplate={(props) => <FormTemplate {...props} showFormControls={false}/>}
4951
schema={schema}
5052
onCancel={() => console.log('canceling')}
5153
/>

0 commit comments

Comments
 (0)