@@ -2,75 +2,73 @@ import React, { useState } from 'react';
2
2
import ReactDOM from 'react-dom' ;
3
3
import { FormRenderer , componentTypes } from '@data-driven-forms/react-form-renderer' ;
4
4
5
- import Grid from '@material-ui/core /Grid' ;
5
+ import Grid from '@mui/material /Grid' ;
6
6
import { componentMapper , FormTemplate } from '../src' ;
7
- import { createMuiTheme } from '@material-ui/core/styles' ;
8
- import { ThemeProvider } from '@material-ui/styles' ;
9
- import Typography from '@material-ui/core/Typography' ;
7
+ import { createTheme } from '@mui/material/styles' ;
8
+ import { ThemeProvider , StyledEngineProvider } from '@mui/material/styles' ;
9
+ import LocalizationProvider from '@mui/lab/LocalizationProvider' ;
10
+ import Typography from '@mui/material/Typography' ;
10
11
import demoSchema from '../../../shared/demoschema' ;
11
12
import fieldArraySchema from './demo-schemas/field-array-schema' ;
13
+ import AdapterDateFns from '@mui/lab/AdapterDateFns' ;
12
14
13
- import Button from '@material-ui/core /Button' ;
15
+ import Button from '@mui/material /Button' ;
14
16
import wizardSchema from './demo-schemas/wizard-schema' ;
15
17
import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types' ;
16
18
17
- const theme = createMuiTheme ( {
18
- typography : {
19
- useNextVariants : true
20
- }
21
- } ) ;
19
+ const theme = createTheme ( ) ;
22
20
23
21
const compositeMapper = {
24
22
...componentMapper ,
25
23
[ componentTypes . SWITCH ] : {
26
24
component : componentMapper [ componentTypes . SWITCH ] ,
27
25
FormControlLabelProps : {
28
- labelPlacement : 'end'
29
- }
30
- }
26
+ labelPlacement : 'end' ,
27
+ } ,
28
+ } ,
31
29
} ;
32
30
33
31
const options = [
34
32
{
35
33
label : 'One' ,
36
- value : 1
34
+ value : 1 ,
37
35
} ,
38
36
{
39
37
label : 'Two' ,
40
- value : 2
38
+ value : 2 ,
41
39
} ,
42
40
{
43
41
label : 'Three' ,
44
- value : 3
42
+ value : 3 ,
45
43
} ,
46
44
{
47
45
label : 'Four' ,
48
- value : 4
46
+ value : 4 ,
49
47
} ,
50
48
{
51
49
label : 'Five' ,
52
- value : 5
50
+ value : 5 ,
53
51
} ,
54
52
{
55
53
label : 'Six' ,
56
- value : 6
54
+ value : 6 ,
57
55
} ,
58
56
{
59
57
label : 'Seven' ,
60
- value : 7
58
+ value : 7 ,
61
59
} ,
62
60
{
63
61
label : 'Eight' ,
64
- value : 8
62
+ value : 8 ,
65
63
} ,
66
64
{
67
65
label : 'Nine' ,
68
- value : 9
66
+ value : 9 ,
69
67
} ,
70
68
{
71
69
label : 'Ten' ,
72
- value : 10
73
- }
70
+ value : 10 ,
71
+ } ,
74
72
] ;
75
73
76
74
const loadOptions = ( filter ) =>
@@ -95,76 +93,80 @@ const selectSchema = {
95
93
isSearchable : true ,
96
94
isRequired : true ,
97
95
validate : [ { type : validatorTypes . REQUIRED } ] ,
98
- closeMenuOnSelect : false
96
+ closeMenuOnSelect : false ,
99
97
} ,
100
98
{
101
99
name : 'default-select' ,
102
100
component : componentTypes . SELECT ,
103
101
label : 'Default select' ,
104
102
options,
105
- placeholder : 'Select'
103
+ placeholder : 'Select' ,
106
104
} ,
107
105
{
108
106
name : 'disabled-select' ,
109
107
component : componentTypes . SELECT ,
110
108
label : 'Disabled select' ,
111
109
options,
112
- isDisabled : true
110
+ isDisabled : true ,
113
111
} ,
114
112
{
115
113
name : 'clearable-select' ,
116
114
component : componentTypes . SELECT ,
117
115
label : 'Clearable select' ,
118
116
options,
119
- isClearable : true
117
+ isClearable : true ,
120
118
} ,
121
119
{
122
120
name : 'multi-select' ,
123
121
component : componentTypes . SELECT ,
124
122
label : 'Multi select' ,
125
123
options,
126
- isMulti : true
124
+ isMulti : true ,
127
125
} ,
128
126
{
129
127
name : 'searchable-select' ,
130
128
component : componentTypes . SELECT ,
131
129
label : 'Searchable select' ,
132
130
options,
133
- isSearchable : true
131
+ isSearchable : true ,
134
132
} ,
135
133
{
136
134
name : 'async-select' ,
137
135
component : componentTypes . SELECT ,
138
136
label : 'Async select' ,
139
- loadOptions
140
- }
141
- ]
137
+ loadOptions,
138
+ } ,
139
+ ] ,
142
140
} ;
143
141
144
142
const App = ( ) => {
145
143
const [ schema , setSchema ] = useState ( wizardSchema ) ;
146
144
147
145
return (
148
- < ThemeProvider theme = { theme } >
149
- < Grid container spacing = { 4 } justify = "center" alignItems = "center" >
150
- < Grid item xs = { 12 } >
151
- < Typography variant = "h3" > Material UI component mapper</ Typography >
152
- </ Grid >
153
- < Grid item xs = { 12 } >
154
- < Button onClick = { ( ) => setSchema ( demoSchema ) } > Demo schema</ Button >
155
- < Button onClick = { ( ) => setSchema ( fieldArraySchema ) } > Field array</ Button >
156
- < Button onClick = { ( ) => setSchema ( wizardSchema ) } > Wizard</ Button >
157
- < Button onClick = { ( ) => setSchema ( selectSchema ) } > Select</ Button >
158
- </ Grid >
159
- < FormRenderer
160
- onSubmit = { console . log }
161
- componentMapper = { compositeMapper }
162
- FormTemplate = { ( props ) => < FormTemplate { ...props } /> }
163
- schema = { schema }
164
- onCancel = { ( ) => console . log ( 'canceling' ) }
165
- />
166
- </ Grid >
167
- </ ThemeProvider >
146
+ < StyledEngineProvider injectFirst >
147
+ < ThemeProvider theme = { theme } >
148
+ < LocalizationProvider dateAdapter = { AdapterDateFns } >
149
+ < Grid container spacing = { 4 } justifyContent = "center" alignItems = "center" >
150
+ < Grid item xs = { 12 } >
151
+ < Typography variant = "h3" > Material UI component mapper</ Typography >
152
+ </ Grid >
153
+ < Grid item xs = { 12 } >
154
+ < Button onClick = { ( ) => setSchema ( demoSchema ) } > Demo schema</ Button >
155
+ < Button onClick = { ( ) => setSchema ( fieldArraySchema ) } > Field array</ Button >
156
+ < Button onClick = { ( ) => setSchema ( wizardSchema ) } > Wizard</ Button >
157
+ < Button onClick = { ( ) => setSchema ( selectSchema ) } > Select</ Button >
158
+ </ Grid >
159
+ < FormRenderer
160
+ onSubmit = { console . log }
161
+ componentMapper = { compositeMapper }
162
+ FormTemplate = { ( props ) => < FormTemplate { ...props } /> }
163
+ schema = { schema }
164
+ onCancel = { ( ) => console . log ( 'canceling' ) }
165
+ />
166
+ </ Grid >
167
+ </ LocalizationProvider >
168
+ </ ThemeProvider >
169
+ </ StyledEngineProvider >
168
170
) ;
169
171
} ;
170
172
0 commit comments