Skip to content

Commit e9a96dd

Browse files
committed
feat: add form doc
1 parent 37c0ab2 commit e9a96dd

26 files changed

+324
-415
lines changed

components/form/demo/advanced-search.md renamed to components/form/demo/advanced-search.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Three columns layout is often used for advanced searching of data table.
1010
Because the width of label is not fixed, you may need to adjust it by customizing its style.
1111
</us>
1212

13-
```html
13+
1414
<script>
1515
import { Form } from 'vue-antd-ui'
1616
@@ -128,7 +128,7 @@ export default {
128128
padding-top: 80px;
129129
}
130130
</style>
131-
```
131+
132132

133133

134134

components/form/demo/coordinated.md renamed to components/form/demo/coordinated.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Use `setFieldsValue` to set other control's value programmaticly.
99
</us>
1010

11-
```html
11+
1212
<script>
1313
import { Form } from 'vue-antd-ui'
1414
@@ -76,7 +76,7 @@ const CoordinatedForm = {
7676
7777
export default Form.create()(CoordinatedForm)
7878
</script>
79-
```
79+
8080

8181

8282

components/form/demo/customized-form-controls.md renamed to components/form/demo/customized-form-controls.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Customized or third-party form controls can be used in Form, too. Controls must
1414
> * It must be a class component.
1515
</us>
1616

17-
```html
17+
1818
<script>
1919
import { Form } from 'vue-antd-ui'
2020
@@ -123,7 +123,7 @@ const Demo = {
123123
124124
export default Form.create()(Demo)
125125
</script>
126-
```
126+
127127

128128

129129

components/form/demo/dynamic-form-item.md renamed to components/form/demo/dynamic-form-item.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Add or remove form items dynamically.
99
</us>
1010

11-
```html
11+
1212
<script>
1313
import { Form } from 'vue-antd-ui'
1414
@@ -138,7 +138,7 @@ export default Form.create()(DynamicFieldSet)
138138
}
139139
</style>
140140

141-
```
141+
142142

143143

144144

components/form/demo/dynamic-rule.md renamed to components/form/demo/dynamic-rule.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Perform different check rules according to different situations.
99
</us>
1010

11-
```html
11+
1212
<script>
1313
import { Form } from 'vue-antd-ui'
1414
@@ -88,7 +88,7 @@ const DynamicRule = {
8888
8989
export default Form.create()(DynamicRule)
9090
</script>
91-
```
91+
9292

9393

9494

components/form/demo/form-in-modal.md renamed to components/form/demo/form-in-modal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
When user visit a page with a list of items, and want to create a new item. The page can popup a form in Modal, then let user fill in the form to create an item.
99
</us>
1010

11-
```html
11+
1212
<script>
1313
import { Form } from 'vue-antd-ui'
1414
@@ -99,7 +99,7 @@ export default {
9999
},
100100
}
101101
</script>
102-
```
102+
103103

104104

105105

components/form/demo/global-state.md renamed to components/form/demo/global-state.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<us>
1010
#### Store Form Data into Upper Component
1111
We can store form data into upper component.
12-
**Note:**
12+
**Note:**
1313
You must wrap field data with `Form.createFormField` in `mapPropsToFields`.
1414
The properties passed by the upper component must be declared in the props of `Form.create({ props: ...})`.
1515
</us>
1616

17-
```html
17+
1818
<script>
1919
import { Form } from 'vue-antd-ui'
2020
@@ -86,7 +86,7 @@ export default {
8686
margin-top: 24px;
8787
}
8888
</style>
89-
```
89+
9090

9191

9292

components/form/demo/horizontal-login.md renamed to components/form/demo/horizontal-login.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Horizontal login form is often used in navigation bar.
99
</us>
1010

11-
```html
11+
1212
<script>
1313
import { Form } from 'vue-antd-ui'
1414
@@ -76,7 +76,7 @@ const HorizontalLoginForm = {
7676
7777
export default Form.create()(HorizontalLoginForm)
7878
</script>
79-
```
79+
8080

8181

8282

components/form/demo/index.vue

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
<script>
2-
3-
// import AdvancedSearch from './advanced-search'
4-
// import Coordinated from './coordinated'
5-
// import CustomizedFormControls from './customized-form-controls'
6-
// import DynamicFormItem from './dynamic-form-item'
7-
// import DynamicRule from './dynamic-rule'
8-
// import FormInModal from './form-in-modal'
9-
// import GlobalState from './global-state'
10-
// import HorizontalLogin from './horizontal-login'
11-
// import Layout from './layout'
12-
// import NormalLogin from './normal-login'
13-
// import Register from './register'
14-
// import TimeRelatedControls from './time-related-controls'
15-
// import ValidateOther from './validate-other'
16-
// import ValidateStatic from './validate-static'
17-
// import WithoutFormCreate from './without-form-create'
18-
import Test from './test'
19-
import TestString from '!raw-loader!./test'
20-
21-
import CN from './../index.zh-CN'
22-
import US from './../index.en-US'
2+
import AdvancedSearch from './advanced-search'
3+
import AdvancedSearchString from '!raw-loader!./advanced-search'
4+
import Coordinated from './coordinated'
5+
import CoordinatedString from '!raw-loader!./coordinated'
6+
import CustomizedFormControls from './customized-form-controls'
7+
import CustomizedFormControlsString from '!raw-loader!./customized-form-controls'
8+
import DynamicFormItem from './dynamic-form-item'
9+
import DynamicFormItemString from '!raw-loader!./dynamic-form-item'
10+
import DynamicRule from './dynamic-rule'
11+
import DynamicRuleString from '!raw-loader!./dynamic-rule'
12+
import FormInModal from './form-in-modal'
13+
import FormInModalString from '!raw-loader!./form-in-modal'
14+
import GlobalState from './global-state'
15+
import GlobalStateString from '!raw-loader!./global-state'
16+
import HorizontalLogin from './horizontal-login'
17+
import HorizontalLoginString from '!raw-loader!./horizontal-login'
18+
import Layout from './layout'
19+
import LayoutString from '!raw-loader!./layout'
20+
import NormalLogin from './normal-login'
21+
import NormalLoginString from '!raw-loader!./normal-login'
22+
import Register from './register'
23+
import RegisterString from '!raw-loader!./register'
24+
import TimeRelatedControls from './time-related-controls'
25+
import TimeRelatedControlsString from '!raw-loader!./time-related-controls'
26+
import ValidateOther from './validate-other'
27+
import ValidateOtherString from '!raw-loader!./validate-other'
28+
import ValidateStatic from './validate-static'
29+
import ValidateStaticString from '!raw-loader!./validate-static'
30+
import WithoutFormCreate from './without-form-create'
31+
import WithoutFormCreateString from '!raw-loader!./without-form-create'
32+
33+
import CN from '../index.zh-CN'
34+
import US from '../index.en-US'
2335
2436
const md = {
2537
cn: `# Form 表单
@@ -70,27 +82,54 @@ export default {
7082
cols: 1,
7183
title: 'Form',
7284
render () {
73-
console.log(TestString)
7485
return (
7586
<div>
7687
<md cn={md.cn} us={md.us} />
77-
<Test />
78-
{/* <AdvancedSearch />
79-
<Coordinated />
80-
<CustomizedFormControls />
81-
<DynamicFormItem />
82-
<DynamicRule />
83-
<FormInModal />
84-
<GlobalState />
85-
<HorizontalLogin />
86-
<Layout />
87-
<NormalLogin />
88-
<Register />
89-
<TimeRelatedControls />
90-
<ValidateStatic />
91-
<WithoutFormCreate />
92-
<ValidateOther />
93-
*/}
88+
<demo-container code={AdvancedSearchString}>
89+
<AdvancedSearch />
90+
</demo-container>
91+
<demo-container code={CoordinatedString}>
92+
<Coordinated />
93+
</demo-container>
94+
<demo-container code={CustomizedFormControlsString}>
95+
<CustomizedFormControls />
96+
</demo-container>
97+
<demo-container code={DynamicFormItemString}>
98+
<DynamicFormItem />
99+
</demo-container>
100+
<demo-container code={DynamicRuleString}>
101+
<DynamicRule />
102+
</demo-container>
103+
<demo-container code={FormInModalString}>
104+
<FormInModal />
105+
</demo-container>
106+
<demo-container code={GlobalStateString}>
107+
<GlobalState />
108+
</demo-container>
109+
<demo-container code={HorizontalLoginString}>
110+
<HorizontalLogin />
111+
</demo-container>
112+
<demo-container code={LayoutString}>
113+
<Layout />
114+
</demo-container>
115+
<demo-container code={NormalLoginString}>
116+
<NormalLogin />
117+
</demo-container>
118+
<demo-container code={RegisterString}>
119+
<Register />
120+
</demo-container>
121+
<demo-container code={TimeRelatedControlsString}>
122+
<TimeRelatedControls />
123+
</demo-container>
124+
<demo-container code={ValidateStaticString}>
125+
<ValidateStatic />
126+
</demo-container>
127+
<demo-container code={WithoutFormCreateString}>
128+
<WithoutFormCreate />
129+
</demo-container>
130+
<demo-container code={ValidateOtherString}>
131+
<ValidateOther />
132+
</demo-container>
94133
<api>
95134
<CN slot='cn' />
96135
<US />
@@ -100,3 +139,8 @@ export default {
100139
},
101140
}
102141
</script>
142+
<style>
143+
.code-box-demo .ant-form:not(.ant-form-inline):not(.ant-form-vertical) {
144+
max-width: 600px;
145+
}
146+
</style>

components/form/demo/layout.md renamed to components/form/demo/layout.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
There are three layout for form: `horizontal`, `vertical`, `inline`.
99
</us>
1010

11-
```html
11+
1212
<template>
1313
<div>
1414
<a-form :layout="formLayout">
@@ -43,7 +43,7 @@ There are three layout for form: `horizontal`, `vertical`, `inline`.
4343
<a-button type='primary'>Submit</a-button>
4444
</a-form-item>
4545
</a-form>
46-
</div>
46+
</div>
4747
</template>
4848

4949
<script>
@@ -75,7 +75,7 @@ export default {
7575
},
7676
}
7777
</script>
78-
```
78+
7979

8080

8181

0 commit comments

Comments
 (0)