|
1 | | -/* eslint-disable react/prop-types */ |
2 | 1 | import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
3 | 3 | import { Grid, Button as MUIButton, Typography } from '@material-ui/core'; |
| 4 | +import { makeStyles } from '@material-ui/core/styles'; |
4 | 5 |
|
5 | 6 | import FormTemplate from '@data-driven-forms/common/src/form-template'; |
6 | 7 |
|
| 8 | +const useStyles = makeStyles(() => ({ |
| 9 | + buttonGroup: { |
| 10 | + display: 'flex', |
| 11 | + justifyContent: 'flex-end' |
| 12 | + } |
| 13 | +})); |
| 14 | + |
7 | 15 | const Form = ({ children, ...props }) => <form {...props}>{children}</form>; |
| 16 | + |
| 17 | +Form.propTypes = { |
| 18 | + children: PropTypes.node |
| 19 | +}; |
| 20 | + |
8 | 21 | const Description = ({ children }) => ( |
9 | 22 | <Grid item xs={12}> |
10 | 23 | <Typography variant="body1" gutterBottom> |
11 | 24 | {children} |
12 | 25 | </Typography> |
13 | 26 | </Grid> |
14 | 27 | ); |
| 28 | + |
| 29 | +Description.propTypes = { |
| 30 | + children: PropTypes.node |
| 31 | +}; |
| 32 | + |
15 | 33 | const Title = ({ children }) => ( |
16 | 34 | <Grid item xs={12}> |
17 | 35 | <Typography variant="h3" gutterBottom> |
18 | 36 | {children} |
19 | 37 | </Typography> |
20 | 38 | </Grid> |
21 | 39 | ); |
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 | + |
23 | 54 | const Button = ({ label, variant, children, buttonType, ...props }) => ( |
24 | 55 | <MUIButton color={variant} variant="contained" {...props}> |
25 | 56 | {label || children} |
26 | 57 | </MUIButton> |
27 | 58 | ); |
28 | 59 |
|
| 60 | +Button.propTypes = { |
| 61 | + children: PropTypes.node, |
| 62 | + label: PropTypes.node, |
| 63 | + variant: PropTypes.string, |
| 64 | + buttonType: PropTypes.string |
| 65 | +}; |
| 66 | + |
29 | 67 | const MuiFormTemplate = (props) => ( |
30 | 68 | <FormTemplate FormWrapper={Form} Button={Button} ButtonGroup={ButtonGroup} Title={Title} Description={Description} {...props} /> |
31 | 69 | ); |
|
0 commit comments