forked from data-driven-forms/react-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (54 loc) · 2.09 KB
/
Copy pathindex.js
File metadata and controls
59 lines (54 loc) · 2.09 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
import React from 'react';
import { createRoot } from 'react-dom/client';
import { FormRenderer } from '@data-driven-forms/react-form-renderer';
import { arraySchemaDDF } from './demo-schemas/widget-schema';
import { componentMapper, FormTemplate } from '../src';
import { wizardSchema } from './demo-schemas/wizard-schema';
import sandboxSchema from './demo-schemas/sandbox';
import demoSchema from '../../../shared/demoschema';
import { Button } from '@carbon/react';
const fieldArrayState = {
schema: arraySchemaDDF,
additionalOptions: {
initialValues: {
number: [1, 2, 3, 4],
minMax: [null, null, null, null],
},
},
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = fieldArrayState;
}
render() {
return (
<div style={{ widht: '100%' }}>
<div style={{ maxWidth: 800, marginLeft: 'auto', marginRight: 'auto' }}>
<h1>carbon component mapper</h1>
<div style={{ marginBottom: 20, marginTop: 20 }}>
<Button
onClick={() => this.setState((state) => ({ schema: wizardSchema, additionalOptions: { showFormControls: false, wizard: true } }))}
>
Wizard
</Button>
<Button onClick={() => this.setState((state) => fieldArrayState)}>arraySchema</Button>
<Button onClick={() => this.setState((state) => ({ schema: sandboxSchema, additionalOptions: {} }))}>Sandbox</Button>
<Button onClick={() => this.setState((state) => ({ schema: demoSchema, additionalOptions: {} }))}>Super schema</Button>
</div>
<FormRenderer
onSubmit={console.log}
componentMapper={componentMapper}
FormTemplate={(props) => <FormTemplate {...props} showFormControls={this.state.additionalOptions.showFormControls} />}
onCancel={console.log}
schema={this.state.schema}
{...this.state.additionalOptions}
/>
</div>
</div>
);
}
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);