Skip to content

Commit a6be195

Browse files
committed
fix(ant): add vertical as default prop to AntForm
1 parent 6f0ee21 commit a6be195

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed
Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,82 @@
1-
/* eslint-disable react/prop-types */
21
import React from 'react';
2+
import PropTypes from 'prop-types';
33
import { Button, Typography, Form as AntForm } from 'antd';
44
import FormTemplate from '@data-driven-forms/common/src/form-template';
5+
import { childrenPropTypes } from '@data-driven-forms/common/src/prop-types-templates';
56

67
const { Title, Paragraph } = Typography;
78

8-
const Form = ({ layout, children, onSubmit, ...props }) => (
9-
<AntForm onFinish={onSubmit} layout={layout ? layout : 'vertical'} {...props}>
9+
const Form = ({ children, onSubmit, ...props }) => (
10+
<AntForm onFinish={onSubmit} {...props}>
1011
{children}
1112
</AntForm>
1213
);
1314

15+
Form.propTypes = {
16+
layout: PropTypes.string,
17+
onSubmit: PropTypes.func,
18+
children: childrenPropTypes
19+
};
20+
21+
Form.defaultProps = {
22+
layout: 'vertical'
23+
};
24+
1425
const Description = ({ children }) => (
1526
<Typography>
1627
<Paragraph>{children}</Paragraph>
1728
</Typography>
1829
);
30+
31+
Description.propTypes = {
32+
children: childrenPropTypes
33+
};
34+
1935
const TitleComponent = ({ children }) => (
2036
<Typography>
2137
<Title level={3}>{children}</Title>
2238
</Typography>
2339
);
2440

41+
TitleComponent.propTypes = {
42+
children: childrenPropTypes
43+
};
44+
2545
const ButtonGroup = ({ children }) => <div style={{ display: 'flex', justifyContent: 'flex-end' }}>{children}</div>;
46+
47+
ButtonGroup.propTypes = {
48+
children: childrenPropTypes
49+
};
50+
2651
const ButtonComponent = ({ label, variant, children, buttonType, ...props }) => (
2752
<Button {...props} type="primary" htmlType={props.type}>
2853
{label || children}
2954
</Button>
3055
);
3156

32-
const AntFormTemplate = (props) => (
57+
ButtonComponent.propTypes = {
58+
children: childrenPropTypes,
59+
label: PropTypes.node,
60+
variant: PropTypes.string,
61+
buttonType: PropTypes.string,
62+
type: PropTypes.string
63+
};
64+
65+
const AntFormTemplate = ({ layout, formWrapperProps, ...props }) => (
3366
<FormTemplate
3467
FormWrapper={Form}
3568
Button={ButtonComponent}
3669
ButtonGroup={ButtonGroup}
3770
Title={TitleComponent}
3871
Description={Description}
39-
formWrapperProps={{ layout: props.layout, ...props.formWrapperProps }}
72+
formWrapperProps={{ layout, ...formWrapperProps }}
4073
{...props}
4174
/>
4275
);
4376

77+
AntFormTemplate.propTypes = {
78+
layout: PropTypes.string,
79+
formWrapperProps: PropTypes.object
80+
};
81+
4482
export default AntFormTemplate;

0 commit comments

Comments
 (0)