Skip to content
This repository was archived by the owner on Jun 1, 2020. It is now read-only.

Commit 0c57167

Browse files
committed
Prettier files and fix SelectWidget
1 parent 480e470 commit 0c57167

File tree

35 files changed

+448
-367
lines changed

35 files changed

+448
-367
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<br />
2323
<p align="center">
2424
<a href="https://github.com/cybertec-postgresql/rjsf-material-ui">
25-
<img src="rjsf-material-ui-logo.png" alt="Logo" width="140" height="120">
25+
<img src="https://raw.githubusercontent.com/cybertec-postgresql/rjsf-material-ui/master/rjsf-material-ui-logo.png" alt="Logo" width="140" height="120">
2626
</a>
2727

2828
<h3 align="center">rjsf-material-ui</h3>

example/src/body/Body.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export default withStyles(styles)(({ classes, selectedDemo }: any) => (
77
<div className={classes.body}>
88
<Example data={selectedDemo} />
99
</div>
10-
));
10+
));

example/src/body/Example.tsx

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,126 @@
11
import React from 'react';
22

3-
import Box from "@material-ui/core/Box";
3+
import Box from '@material-ui/core/Box';
44
import Button from '@material-ui/core/Button';
55
import { createStyles, withStyles } from '@material-ui/core/styles';
66
import Paper from '@material-ui/core/Paper';
77
import Typography from '@material-ui/core/Typography';
88

99
import styles from './example-styles';
1010
import Source from './Source';
11-
//import Form from '../form';
1211

13-
import Form from "../../../src"
12+
import Form from '../../../src';
1413

15-
const formStyles = theme => createStyles({
16-
field: {
17-
paddingLeft: theme.spacing.unit * 4,
18-
},
19-
formButtons: {
20-
order: 2,
21-
},
22-
root: {
23-
display: 'flex',
24-
padding: theme.spacing.unit,
25-
},
26-
});
14+
const formStyles = theme =>
15+
createStyles({
16+
field: {
17+
paddingLeft: theme.spacing.unit * 4,
18+
},
19+
formButtons: {
20+
order: 2,
21+
},
22+
root: {
23+
display: 'flex',
24+
padding: theme.spacing.unit,
25+
},
26+
});
2727

2828
class Example extends React.Component<any, any> {
2929
state = {
30-
...this.props.data, // eslint-disable-line react/destructuring-assignment
31-
}
30+
...this.props.data,
31+
};
3232

3333
componentWillReceiveProps = ({ data }) => {
3434
this.setState({
3535
...data,
3636
});
37-
}
37+
};
3838

39-
onChange = type => (value) => {
39+
onChange = type => value => {
4040
this.setState({
4141
[type]: value,
4242
});
43-
}
43+
};
4444

4545
onFormChanged = ({ formData }) => {
4646
this.setState({ formData });
47-
}
47+
};
4848

49-
onSubmit = (value) => {
49+
onSubmit = value => {
5050
console.log('onSubmit:', value); // eslint-disable-line no-console
51-
}
51+
};
5252

5353
onCancel = () => {
5454
const { data } = this.props;
5555
this.setState({
5656
...data,
5757
});
58-
}
58+
};
5959

6060
render() {
6161
const { data, classes } = this.props;
62-
const { title} = data;
62+
const { title } = data;
6363
const { schema, uiSchema, formData } = this.state;
6464
return (
6565
<Paper className={classes.root}>
66-
<Typography component="h4" variant="h4">{title}</Typography>
66+
<Typography component="h4" variant="h4">
67+
{title}
68+
</Typography>
6769
<br />
6870
<div className={classes.ctr}>
6971
<div className={classes.sourceCtr}>
7072
<div>
71-
<Source title={'JSONSchema'} source={schema} onChange={this.onChange('schema')} />
73+
<Source
74+
title={'JSONSchema'}
75+
source={schema}
76+
onChange={this.onChange('schema')}
77+
/>
7278
</div>
7379
<div>
74-
<Source title={'uiSchema'} source={uiSchema} onChange={this.onChange('uiSchema')} />
75-
<Source title={'formData'} source={formData} onChange={this.onChange('formData')} />
80+
<Source
81+
title={'uiSchema'}
82+
source={uiSchema}
83+
onChange={this.onChange('uiSchema')}
84+
/>
85+
<Source
86+
title={'formData'}
87+
source={formData}
88+
onChange={this.onChange('formData')}
89+
/>
7690
</div>
7791
</div>
7892
<div className={classes.display}>
7993
<Paper elevation={2}>
80-
<Box p={2}>
81-
<Form
82-
//styles={formStyles}
83-
schema={schema}
84-
uiSchema={uiSchema}
85-
formData={formData}
86-
onSubmit={this.onSubmit}
87-
onChange={this.onFormChanged}
88-
//cancelText={'Cancel'}
89-
//submitText={'Save'}
90-
//showErrorList={showErrorList}
91-
//showHelperError={showHelperError}
92-
//ErrorList={ErrorList}
93-
>
94-
<Box mt={2}>
95-
<Button variant="contained" color="default" onClick={this.onCancel}>Cancel</Button>
96-
<Button variant="contained" color="primary" type="submit">Submit</Button>
97-
</Box>
98-
</Form>
99-
</Box>
94+
<Box p={2}>
95+
<Form
96+
schema={schema}
97+
uiSchema={uiSchema}
98+
formData={formData}
99+
onSubmit={this.onSubmit}
100+
onChange={this.onFormChanged}
101+
//showErrorList={showErrorList}
102+
//showHelperError={showHelperError}
103+
>
104+
<Box mt={2}>
105+
<Button
106+
variant="contained"
107+
color="default"
108+
onClick={this.onCancel}
109+
>
110+
Cancel
111+
</Button>
112+
<Button variant="contained" color="primary" type="submit">
113+
Submit
114+
</Button>
115+
</Box>
116+
</Form>
117+
</Box>
100118
</Paper>
101119
</div>
102120
</div>
103121
</Paper>
104122
);
105123
}
106124
}
107-
export default withStyles(styles)(Example);
125+
126+
export default withStyles(styles)(Example);

example/src/body/Source.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import React from 'react';
2+
23
import classNames from 'classnames';
4+
35
import { Controlled as CodeMirror } from 'react-codemirror2';
46
import 'codemirror/lib/codemirror.css';
57
import 'codemirror/theme/material.css';
6-
import 'codemirror/mode/javascript/javascript'; // eslint-disable-line
8+
import 'codemirror/mode/javascript/javascript';
9+
// eslint-disable-line
710
import Valid from '@material-ui/icons/CheckCircle';
811
import Invalid from '@material-ui/icons/HighlightOff';
912
import { withStyles } from '@material-ui/core/styles';
13+
1014
import sourceStyles from './editor-styles';
1115

1216
const cmOptions = {
@@ -18,12 +22,11 @@ const cmOptions = {
1822
readOnly: false,
1923
};
2024

21-
const isValid = (value) => {
25+
const isValid = value => {
2226
let obj;
2327
try {
2428
obj = JSON.parse(value);
25-
}
26-
catch (e) {
29+
} catch (e) {
2730
return false;
2831
}
2932
return obj;
@@ -39,17 +42,17 @@ class Source extends React.Component<any, any> {
3942
};
4043
}
4144

42-
componentWillReceiveProps = (nextProps) => {
45+
componentWillReceiveProps = nextProps => {
4346
const source = JSON.stringify(nextProps.source, null, 2);
4447
this.setState({
4548
source,
4649
valid: isValid(source),
4750
});
48-
}
51+
};
4952

5053
onChange = (editor, data, value) => {
5154
this.setState({ source: value });
52-
}
55+
};
5356

5457
onBeforeChange = (editor, data, value) => {
5558
const { onChange } = this.props;
@@ -62,7 +65,7 @@ class Source extends React.Component<any, any> {
6265
if (parsed && onChange) {
6366
onChange(parsed);
6467
}
65-
}
68+
};
6669

6770
render() {
6871
const { source, valid } = this.state;
@@ -91,4 +94,4 @@ class Source extends React.Component<any, any> {
9194
}
9295
}
9396

94-
export default withStyles(sourceStyles)(Source);
97+
export default withStyles(sourceStyles)(Source);

example/src/body/body-styles.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Theme } from "@material-ui/core/styles";
1+
import { Theme } from '@material-ui/core/styles';
22

33
export default (theme: Theme) => ({
4-
body: {
5-
'padding': theme.spacing(2),
6-
[theme.breakpoints.up('lg')]: {
7-
width: 'calc(100% - 250px)',
8-
marginLeft: 250,
9-
},
4+
body: {
5+
padding: theme.spacing(2),
6+
[theme.breakpoints.up('lg')]: {
7+
width: 'calc(100% - 250px)',
8+
marginLeft: 250,
109
},
11-
});
10+
},
11+
});

example/src/body/editor-styles.ts

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
import { Theme } from "@material-ui/core/styles";
1+
import { Theme } from '@material-ui/core/styles';
22

33
export default (theme: Theme) => ({
4-
'root': {
5-
'& $ctr': {
6-
'borderStyle': 'solid',
7-
'borderWidth': 1,
8-
'borderColor': theme.palette.grey[500],
9-
'borderRadius': '5px',
10-
'flexDirection': 'column' as 'column',
11-
'display': 'flex',
12-
'&$invalid': {
13-
'& $icon': {
14-
color: 'red',
15-
},
16-
},
4+
root: {
5+
'& $ctr': {
6+
borderStyle: 'solid',
7+
borderWidth: 1,
8+
borderColor: theme.palette.grey[500],
9+
borderRadius: '5px',
10+
flexDirection: 'column' as 'column',
11+
display: 'flex',
12+
'&$invalid': {
1713
'& $icon': {
18-
color: 'green',
19-
},
20-
'& >div:first-child': {
21-
'display': 'flex',
22-
'alignItems': 'center',
23-
'borderBottomStyle': 'solid' as 'solid',
24-
'borderBottomWidth': 1,
25-
'borderColor': theme.palette.grey[500],
26-
'backgroundColor': theme.palette.grey[300],
14+
color: 'red',
2715
},
2816
},
17+
'& $icon': {
18+
color: 'green',
19+
},
20+
'& >div:first-child': {
21+
display: 'flex',
22+
alignItems: 'center',
23+
borderBottomStyle: 'solid' as 'solid',
24+
borderBottomWidth: 1,
25+
borderColor: theme.palette.grey[500],
26+
backgroundColor: theme.palette.grey[300],
27+
},
2928
},
30-
31-
'icon': {
32-
fontSize: 'inherit',
33-
marginLeft: theme.spacing(2),
34-
},
35-
'title': {
36-
'marginLeft': theme.spacing(2),
37-
},
38-
'invalid': {
39-
40-
},
41-
'ctr': {},
42-
});
29+
},
30+
31+
icon: {
32+
fontSize: 'inherit',
33+
marginLeft: theme.spacing(2),
34+
},
35+
title: {
36+
marginLeft: theme.spacing(2),
37+
},
38+
invalid: {},
39+
ctr: {},
40+
});

example/src/body/example-data.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@ import examples from '../examples';
22

33
const { simple, nested } = examples;
44

5-
export default ({
5+
export default {
66
simple: {
77
title: 'Simple',
8-
examples: [
9-
simple,
10-
],
8+
examples: [simple],
119
},
1210
nested: {
1311
title: 'Nested',
14-
examples: [
15-
nested,
16-
],
12+
examples: [nested],
1713
},
18-
});
14+
};

0 commit comments

Comments
 (0)