-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathform-template.js
More file actions
49 lines (41 loc) · 1.28 KB
/
form-template.js
File metadata and controls
49 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import { Button, Typography, Form as AntForm } from 'antd';
import FormTemplate from '@data-driven-forms/common/form-template';
const { Title, Paragraph } = Typography;
const Form = ({ children, onSubmit, layout = 'vertical', ...props }) => (
<AntForm onFinish={onSubmit} layout={layout} {...props}>
{children}
</AntForm>
);
const Description = ({ children, ...props }) => (
<Typography {...props}>
<Paragraph>{children}</Paragraph>
</Typography>
);
const TitleComponent = ({ children, ...props }) => (
<Typography {...props}>
<Title level={3}>{children}</Title>
</Typography>
);
const ButtonGroup = ({ children, ...props }) => (
<div style={{ display: 'flex', justifyContent: 'flex-end' }} {...props}>
{children}
</div>
);
const ButtonComponent = ({ label, variant, children, buttonType, ...props }) => (
<Button {...props} type="primary" htmlType={props.type}>
{label || children}
</Button>
);
const AntFormTemplate = ({ layout, formWrapperProps, ...props }) => (
<FormTemplate
FormWrapper={Form}
Button={ButtonComponent}
ButtonGroup={ButtonGroup}
Title={TitleComponent}
Description={Description}
formWrapperProps={{ layout, ...formWrapperProps }}
{...props}
/>
);
export default AntFormTemplate;