Skip to content

Commit d41215f

Browse files
committed
Added FormWrapper in FormTemplate
1 parent 45254ef commit d41215f

File tree

7 files changed

+4028
-4512
lines changed

7 files changed

+4028
-4512
lines changed

package.json

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
]
4444
},
4545
"devDependencies": {
46-
"@babel/plugin-transform-runtime": "^7.10.3",
46+
"@babel/plugin-transform-runtime": "^7.9.0",
4747
"@babel/preset-typescript": "^7.9.0",
4848
"@khala/commit-analyzer-wildcard": "^2.4.1",
4949
"@khala/npm-release-monorepo": "^2.4.1",
@@ -64,44 +64,31 @@
6464
"eslint-config-react-app": "^5.2.0",
6565
"eslint-loader": "^3.0.3",
6666
"eslint-plugin-flowtype": "^4.6.0",
67-
"eslint-plugin-import": "^2.22.0",
68-
"eslint-plugin-jsx-a11y": "^6.3.1",
69-
"eslint-plugin-prettier": "^3.1.4",
70-
"eslint-plugin-react": "^7.20.1",
67+
"eslint-plugin-import": "^2.20.1",
68+
"eslint-plugin-jsx-a11y": "^6.2.3",
69+
"eslint-plugin-prettier": "^3.1.2",
70+
"eslint-plugin-react": "^7.18.3",
7171
"eslint-plugin-react-hooks": "^2.4.0",
7272
"glob": "^7.1.6",
7373
"identity-obj-proxy": "^3.0.0",
7474
"inquirer": "^7.1.0",
7575
"jest": "^24.8.0",
76-
"lerna": "^3.22.1",
76+
"lerna": "^3.13.1",
7777
"ncp": "^2.0.0",
7878
"prettier": "^1.19.1",
7979
"replace-in-file": "^6.0.0",
8080
"semantic-release": "^16.0.4",
8181
"source-map-loader": "^0.2.4",
8282
"strip-ansi": "^6.0.0",
83-
"terser-webpack-plugin": "^1.4.4",
83+
"terser-webpack-plugin": "^1.3.0",
8484
"ts-loader": "^7.0.5",
8585
"tslint": "^6.1.2",
8686
"tslint-config-prettier": "^1.18.0",
8787
"typescript": "^3.9.3"
8888
},
8989
"release": {
9090
"monorepo": "./packages",
91-
"branches": [
92-
"+([0-9])?(.{+([0-9]),x}).x",
93-
"master",
94-
"next",
95-
"next-major",
96-
{
97-
"name": "beta",
98-
"prerelease": true
99-
},
100-
{
101-
"name": "alpha",
102-
"prerelease": true
103-
}
104-
],
91+
"branches": ["+([0-9])?(.{+([0-9]),x}).x", "master", "next", "next-major", {"name": "beta", "prerelease": true}, {"name": "alpha", "prerelease": true}],
10592
"plugins": [
10693
"@khala/npm-release-monorepo",
10794
[

packages/ant-component-mapper/demo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const App = () => (
1818
<div style={style}>
1919
<FormRenderer
2020
componentMapper={componentMapper}
21-
FormTemplate={(props) => <FormTemplate {...props} />}
21+
FormTemplate={(props) => <FormTemplate layout='vertical' {...props} />}
2222
onSubmit={console.log}
2323
schema={demoSchema}
2424
/>

packages/ant-component-mapper/src/common/form-wrapper.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,9 @@ import { Form } from 'antd';
55

66
const AntForm = ({ label, children, layout, component, invalid, isRequired, help }) => {
77
return (
8-
<Form layout={layout} component={component}>
9-
<Form.Item
10-
validateStatus={!invalid ? '' : 'error'}
11-
rules={[
12-
{
13-
required: isRequired,
14-
message: 'Required'
15-
}
16-
]}
17-
help={help}
18-
label={label}
19-
name={label}
20-
>
21-
<div>{children}</div>
22-
</Form.Item>
23-
</Form>
8+
<Form.Item validateStatus={!invalid ? '' : 'error'} help={help} label={label} name={label}>
9+
<div>{children}</div>
10+
</Form.Item>
2411
);
2512
};
2613

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
/* eslint-disable react/prop-types */
22
import React from 'react';
3-
import { Button, Typography } from 'antd';
3+
import { Button, Typography, Form as AntForm } from 'antd';
44
import FormTemplate from '@data-driven-forms/common/src/form-template';
55

66
const { Title, Paragraph } = Typography;
77

8-
const Form = ({ children, ...props }) => <form {...props}>{children}</form>;
8+
const Form = ({ layout, children, onSubmit, ...props }) => (
9+
<AntForm onFinish={onSubmit} layout={layout ? layout : 'vertical'}>
10+
{children}
11+
</AntForm>
12+
);
13+
914
const Description = ({ children }) => (
1015
<Typography>
1116
<Paragraph>{children}</Paragraph>
@@ -25,7 +30,15 @@ const ButtonComponent = ({ label, variant, children, buttonType, ...props }) =>
2530
);
2631

2732
const AntFormTemplate = (props) => (
28-
<FormTemplate FormWrapper={Form} Button={ButtonComponent} ButtonGroup={ButtonGroup} Title={TitleComponent} Description={Description} {...props} />
33+
<FormTemplate
34+
FormWrapper={Form}
35+
Button={ButtonComponent}
36+
ButtonGroup={ButtonGroup}
37+
Title={TitleComponent}
38+
Description={Description}
39+
formWrapperProps={{ layout: props.layout }}
40+
{...props}
41+
/>
2942
);
3043

3144
export default AntFormTemplate;

packages/ant-component-mapper/src/files/wizard/wizard-step.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import React, { Fragment } from 'react';
22
import PropTypes from 'prop-types';
33
import WizardStepButtons from './step-buttons';
44

5-
const style = {
6-
minHeight: '250px'
7-
};
8-
95
const WizardStep = ({ fields, formOptions, ...rest }) => (
106
<Fragment>
11-
<div style={style}>{fields.map((item) => formOptions.renderForm([item], formOptions))}</div>
7+
<div className="style">{fields.map((item) => formOptions.renderForm([item], formOptions))}</div>
128
{/* maybe this button could be in a sperate footer such that the position remains constant */}
139
<WizardStepButtons formOptions={formOptions} {...rest} />
1410
</Fragment>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style {
2+
min-height: 250px;
3+
}

0 commit comments

Comments
 (0)