Skip to content

Commit 6c3fa83

Browse files
authored
Merge pull request #400 from rvsia/technicalDebts
[V2] Technical debts
2 parents a0506ee + f8bbd41 commit 6c3fa83

File tree

80 files changed

+420
-21065
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+420
-21065
lines changed

packages/common/src/form-template.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const completeButtons = (buttonOrder) => {
1818
expectedOrder.push('cancel');
1919
}
2020

21-
return Array.from(new Set(expectedOrder));
21+
return expectedOrder;
2222
};
2323

2424
export const FormControls = ({
@@ -37,7 +37,7 @@ export const FormControls = ({
3737
formSpyProps
3838
}) => {
3939
if (FormButtons) {
40-
return <FormButtons {...formSpyProps} />;
40+
return <FormButtons />;
4141
}
4242

4343
const { submitting, pristine, validating } = formSpyProps;
@@ -71,7 +71,6 @@ FormControls.propTypes = {
7171
buttonOrder: PropTypes.arrayOf(PropTypes.string),
7272
buttonClassName: PropTypes.string,
7373
FormButtons: PropTypes.oneOfType([PropTypes.node, PropTypes.element, PropTypes.func]),
74-
FormSpy: PropTypes.oneOfType([PropTypes.node, PropTypes.element, PropTypes.func]),
7574
Button: PropTypes.oneOfType([PropTypes.node, PropTypes.element, PropTypes.func]),
7675
ButtonGroup: PropTypes.oneOfType([PropTypes.node, PropTypes.element, PropTypes.func]),
7776
formSpyProps: PropTypes.shape({

packages/mui-component-mapper/package.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,6 @@
6565
"react": "^16.13.0",
6666
"react-dom": "^16.13.0"
6767
},
68-
"release": {
69-
"prepare": [
70-
"@semantic-release/npm",
71-
{
72-
"path": "@semantic-release/git",
73-
"assets": [
74-
"package.json"
75-
],
76-
"message": "Release of new version: ${nextRelease.version} <no> [skip ci]"
77-
}
78-
]
79-
},
8068
"dependencies": {
8169
"@date-io/date-fns": "^1.0.1",
8270
"@date-io/moment": "^1.0.1",

packages/mui-component-mapper/scripts/update_demo.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { componentTypes } from '@data-driven-forms/react-form-renderer';
22
import SubForm from './sub-form';
33
import Tabs from './tabs';
44
import TextField from './text-field';
5-
import TextArea from './text-area';
5+
import Textarea from './textarea';
66
import Checkbox from './checkbox';
77
import Switch from './switch';
88
import TimePicker from './time-picker';
@@ -14,7 +14,7 @@ import Wizard from './wizard';
1414

1515
export const components = {
1616
TextField,
17-
TextArea,
17+
Textarea,
1818
Select,
1919
Checkbox,
2020
Radio,
@@ -28,7 +28,7 @@ export const components = {
2828

2929
const componentMapper = {
3030
[componentTypes.TEXT_FIELD]: TextField,
31-
[componentTypes.TEXTAREA]: TextArea,
31+
[componentTypes.TEXTAREA]: Textarea,
3232
[componentTypes.SELECT]: Select,
3333
[componentTypes.CHECKBOX]: Checkbox,
3434
[componentTypes.SUB_FORM]: SubForm,

packages/mui-component-mapper/src/files/form-template.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,69 @@
1-
/* eslint-disable react/prop-types */
21
import React from 'react';
2+
import PropTypes from 'prop-types';
33
import { Grid, Button as MUIButton, Typography } from '@material-ui/core';
4+
import { makeStyles } from '@material-ui/core/styles';
45

56
import FormTemplate from '@data-driven-forms/common/src/form-template';
67

8+
const useStyles = makeStyles(() => ({
9+
buttonGroup: {
10+
display: 'flex',
11+
justifyContent: 'flex-end'
12+
}
13+
}));
14+
715
const Form = ({ children, ...props }) => <form {...props}>{children}</form>;
16+
17+
Form.propTypes = {
18+
children: PropTypes.node
19+
};
20+
821
const Description = ({ children }) => (
922
<Grid item xs={12}>
1023
<Typography variant="body1" gutterBottom>
1124
{children}
1225
</Typography>
1326
</Grid>
1427
);
28+
29+
Description.propTypes = {
30+
children: PropTypes.node
31+
};
32+
1533
const Title = ({ children }) => (
1634
<Grid item xs={12}>
1735
<Typography variant="h3" gutterBottom>
1836
{children}
1937
</Typography>
2038
</Grid>
2139
);
22-
const ButtonGroup = ({ children }) => <div style={{ display: 'flex', justifyContent: 'flex-end' }}>{children}</div>;
40+
41+
Title.propTypes = {
42+
children: PropTypes.node
43+
};
44+
45+
const ButtonGroup = ({ children }) => {
46+
const classes = useStyles();
47+
return <div className={classes.buttonGroup}>{children}</div>;
48+
};
49+
50+
ButtonGroup.propTypes = {
51+
children: PropTypes.node
52+
};
53+
2354
const Button = ({ label, variant, children, buttonType, ...props }) => (
2455
<MUIButton color={variant} variant="contained" {...props}>
2556
{label || children}
2657
</MUIButton>
2758
);
2859

60+
Button.propTypes = {
61+
children: PropTypes.node,
62+
label: PropTypes.node,
63+
variant: PropTypes.string,
64+
buttonType: PropTypes.string
65+
};
66+
2967
const MuiFormTemplate = (props) => (
3068
<FormTemplate FormWrapper={Form} Button={Button} ButtonGroup={ButtonGroup} Title={Title} Description={Description} {...props} />
3169
);

packages/mui-component-mapper/src/files/plain-text.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react';
22
import { Typography } from '@material-ui/core';
33
import PropTypes from 'prop-types';
44

5-
const PlainText = ({ label, name }) =>
5+
const PlainText = ({ label, name, ...props }) =>
66
label.split('\n').map((paragraph, index) => (
7-
<Typography key={`${index}-${name}`} gutterBottom variant="body1">
7+
<Typography key={`${index}-${name}`} {...props}>
88
{paragraph}
99
</Typography>
1010
));
@@ -14,4 +14,9 @@ PlainText.propTypes = {
1414
name: PropTypes.string.isRequired
1515
};
1616

17+
PlainText.defaultProps = {
18+
variant: 'body1',
19+
gutterBottom: true
20+
};
21+
1722
export default PlainText;

packages/mui-component-mapper/src/files/radio.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Radio as MUIRadio, FormControlLabel, FormControl, FormLabel, FormHelperText } from '@material-ui/core';
44
import { wrapperProps } from '@data-driven-forms/common/src/multiple-choice-list';
5+
import { makeStyles } from '@material-ui/core/styles';
56

67
import FormFieldGrid from '../common/form-field-grid';
78
import { validationError } from '../common/helpers';
8-
import './radio.scss';
99
import { useFieldApi } from '@data-driven-forms/react-form-renderer';
1010

11+
const useStyles = makeStyles(() => ({
12+
grid: {
13+
'&:first-child': {
14+
marginTop: 8
15+
}
16+
}
17+
}));
18+
1119
const RadioOption = ({ name, option, isDisabled, isReadOnly }) => {
1220
const { input } = useFieldApi({ name, type: 'radio', value: option.value });
1321
return (
@@ -42,10 +50,11 @@ const Radio = ({ name, ...props }) => {
4250
name,
4351
type: 'radio'
4452
});
53+
const classes = useStyles();
4554
const invalid = validationError(meta, validateOnMount);
4655
const text = invalid || helperText || description;
4756
return (
48-
<FormFieldGrid className="mui-ddform-radio-group">
57+
<FormFieldGrid className={classes.grid}>
4958
<FormControl required={isRequired} error={!!invalid} component="fieldset">
5059
<FormLabel component="legend">{label}</FormLabel>
5160
{options.map((option) => (

packages/mui-component-mapper/src/files/radio.scss

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const Select = (props) => {
2121
invalid={invalid}
2222
textFieldProps={{
2323
label,
24-
color: invalid ? 'red' : 'blue',
2524
InputLabelProps: {
2625
shrink: true
2726
}

packages/mui-component-mapper/src/files/sub-form.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Typography, Grid } from '@material-ui/core';
4+
import { makeStyles } from '@material-ui/core/styles';
45

56
import { useFormApi } from '@data-driven-forms/react-form-renderer';
67

7-
const SubForm = ({ fields, title, description, FormSpyProvider: _FormSpyProvider, validate: _validate, ...rest }) => {
8+
const useStyles = makeStyles(() => ({
9+
grid: {
10+
paddingRight: 0,
11+
paddingLeft: 0
12+
}
13+
}));
14+
15+
const SubForm = ({ fields, title, description, ...rest }) => {
816
const { renderForm } = useFormApi();
17+
const classes = useStyles();
18+
919
return (
10-
<Grid item xs={12} container style={{ paddingRight: 0, paddingLeft: 0 }} {...rest}>
20+
<Grid item xs={12} container className={classes.grid} {...rest}>
1121
{title && (
1222
<Grid item xs={12}>
1323
<Typography variant="h5">{title}</Typography>
@@ -28,9 +38,7 @@ const SubForm = ({ fields, title, description, FormSpyProvider: _FormSpyProvider
2838
SubForm.propTypes = {
2939
fields: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
3040
title: PropTypes.string,
31-
description: PropTypes.string,
32-
FormSpyProvider: PropTypes.any,
33-
validate: PropTypes.any
41+
description: PropTypes.string
3442
};
3543

3644
export default SubForm;

0 commit comments

Comments
 (0)