Skip to content

Commit 3a16bb3

Browse files
committed
chore: update n-form to form-model
1 parent 6c4b8ec commit 3a16bb3

File tree

15 files changed

+72
-72
lines changed

15 files changed

+72
-72
lines changed

CHANGELOG.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- 🔥🔥🔥 [Descriptions](https://antdv.com/components/descriptions/) Display multiple read-only fields in groups.
2020
- 🔥🔥🔥 [PageHeader](https://antdv.com/components/page-header/) can be used to declare the topic of the page, display important information about the page that the user is concerned about, and carry the operation items related to the current page.
2121
- 🔥🔥🔥 [Result](https://antdv.com/components/result) is used to feedback the processing results of a series of operation tasks.
22-
- 🔥🔥🔥 [NewForm](https://antdv.com/components/n-form) Form components that use v-model for automatic validation are more concise than v-decorator forms.
22+
- 🔥🔥🔥 [FormModel](https://antdv.com/components/form-model) Form components that use v-model for automatic validation are more concise than v-decorator forms.
2323
- 🔥 Descriptions supports vertical layout.
2424
- 🔥 Progress.Circle supports gradient colors.
2525
- 🔥 Progress.Line supports gradient colors.

CHANGELOG.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- 🔥🔥🔥 [Descriptions](https://antdv.com/components/descriptions-cn/) 成组展示多个只读字段。
2020
- 🔥🔥🔥 [PageHeader](https://antdv.com/components/page-header-cn/) 可用于声明页面主题、展示用户所关注的页面重要信息,以及承载与当前页相关的操作项。
2121
- 🔥🔥🔥 [Result](https://antdv.com/components/result) 用于反馈一系列操作任务的处理结果。
22-
- 🔥🔥🔥 [NewForm](https://antdv.com/components/n-form) 使用 v-model 进行自动校验的表单组件,相较于 v-decorator 形式的表单,更加简洁。
22+
- 🔥🔥🔥 [FormModel](https://antdv.com/components/form-model) 使用 v-model 进行自动校验的表单组件,相较于 v-decorator 形式的表单,更加简洁。
2323
- 🔥 Descriptions 支持垂直布局。
2424
- 🔥 Progress.Circle 支持渐变色。
2525
- 🔥 Progress.Line 支持渐变色。

antdv-demo

components/n-form/Form.jsx renamed to components/form-model/Form.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const ValidationRule = {
4646
};
4747

4848
const Form = {
49-
name: 'ANForm',
49+
name: 'AFormModel',
5050
props: initDefaultProps(FormProps, {
5151
layout: 'horizontal',
5252
hideRequiredMark: false,
@@ -58,7 +58,7 @@ const Form = {
5858
},
5959
provide() {
6060
return {
61-
FormContext: this,
61+
FormModelContext: this,
6262
};
6363
},
6464
inject: {
@@ -96,7 +96,7 @@ const Form = {
9696
},
9797
resetFields() {
9898
if (!this.model) {
99-
warning(false, 'NewForm', 'model is required for resetFields to work.');
99+
warning(false, 'FormModel', 'model is required for resetFields to work.');
100100
return;
101101
}
102102
this.fields.forEach(field => {
@@ -115,7 +115,7 @@ const Form = {
115115
},
116116
validate(callback) {
117117
if (!this.model) {
118-
warning(false, 'NewForm', 'model is required for resetFields to work.');
118+
warning(false, 'FormModel', 'model is required for resetFields to work.');
119119
return;
120120
}
121121
let promise;
@@ -153,7 +153,7 @@ const Form = {
153153
props = [].concat(props);
154154
const fields = this.fields.filter(field => props.indexOf(field.prop) !== -1);
155155
if (!fields.length) {
156-
warning(false, 'NewForm', 'please pass correct props!');
156+
warning(false, 'FormModel', 'please pass correct props!');
157157
return;
158158
}
159159
fields.forEach(field => {

components/n-form/FormItem.jsx renamed to components/form-model/FormItem.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const FormItemProps = {
6262
};
6363

6464
export default {
65-
name: 'ANFormItem',
65+
name: 'AFormModelItem',
6666
__ANT_NEW_FORM_ITEM: true,
6767
mixins: [BaseMixin],
6868
props: initDefaultProps(FormItemProps, {
@@ -71,12 +71,12 @@ export default {
7171
}),
7272
provide() {
7373
return {
74-
NewFormItemContext: this,
74+
FormModelItemContext: this,
7575
};
7676
},
7777
inject: {
7878
configProvider: { default: () => ConfigConsumerProps },
79-
FormContext: { default: () => ({}) },
79+
FormModelContext: { default: () => ({}) },
8080
},
8181
data() {
8282
return {
@@ -89,7 +89,7 @@ export default {
8989

9090
computed: {
9191
fieldValue() {
92-
const model = this.FormContext.model;
92+
const model = this.FormModelContext.model;
9393
if (!model || !this.prop) {
9494
return;
9595
}
@@ -121,13 +121,13 @@ export default {
121121
},
122122
mounted() {
123123
if (this.prop) {
124-
const { addField } = this.FormContext;
124+
const { addField } = this.FormModelContext;
125125
addField && addField(this);
126126
this.initialValue = cloneDeep(this.fieldValue);
127127
}
128128
},
129129
beforeDestroy() {
130-
const { removeField } = this.FormContext;
130+
const { removeField } = this.FormModelContext;
131131
removeField && removeField(this);
132132
},
133133
methods: {
@@ -153,13 +153,13 @@ export default {
153153
this.validateState = errors ? 'error' : 'success';
154154
this.validateMessage = errors ? errors[0].message : '';
155155
callback(this.validateMessage, invalidFields);
156-
this.FormContext &&
157-
this.FormContext.$emit &&
158-
this.FormContext.$emit('validate', this.prop, !errors, this.validateMessage || null);
156+
this.FormModelContext &&
157+
this.FormModelContext.$emit &&
158+
this.FormModelContext.$emit('validate', this.prop, !errors, this.validateMessage || null);
159159
});
160160
},
161161
getRules() {
162-
let formRules = this.FormContext.rules;
162+
let formRules = this.FormModelContext.rules;
163163
const selfRules = this.rules;
164164
const requiredRule =
165165
this.required !== undefined ? { required: !!this.required, trigger: 'change' } : [];
@@ -198,7 +198,7 @@ export default {
198198
resetField() {
199199
this.validateState = '';
200200
this.validateMessage = '';
201-
let model = this.FormContext.model || {};
201+
let model = this.FormModelContext.model || {};
202202
let value = this.fieldValue;
203203
let path = this.prop;
204204
if (path.indexOf(':') !== -1) {

0 commit comments

Comments
 (0)