From e689a1f9d023cbdd9fb109377bd6026d9a87dde3 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Mon, 2 Mar 2020 14:44:26 +0800 Subject: [PATCH] feat(form): data input component will use form or form-items size as size if its size is not passed --- src/AutoComplete/src/main.vue | 10 ++++++---- src/Cascader/src/Cascader.vue | 12 +++++++----- src/DatePicker/src/DatePicker.vue | 10 ++++++---- src/Form/src/Form.vue | 6 ++++++ src/Form/src/FormItem.vue | 25 ++++++++++++++++++++++++- src/Input/src/Input.vue | 8 +++++--- src/InputNumber/src/main.vue | 8 +++++--- src/Select/src/Select.vue | 12 +++++++----- src/TimePicker/src/main.vue | 4 ++-- src/Transfer/src/Transfer.vue | 6 +++--- src/_mixins/asformitem.js | 13 ++++++++++++- 11 files changed, 83 insertions(+), 31 deletions(-) diff --git a/src/AutoComplete/src/main.vue b/src/AutoComplete/src/main.vue index 18340c12f..8c56b2bdc 100644 --- a/src/AutoComplete/src/main.vue +++ b/src/AutoComplete/src/main.vue @@ -8,7 +8,7 @@ @compositionend="handleCompositionEnd" > - +
@@ -75,7 +75,7 @@ :active="active && selectMenuActive" :theme="syntheticTheme" :pattern="pattern" - :size="size" + :size="syntheticSize" :multiple="multiple" :options="menuOptions" @input="handleMenuInput" @@ -142,8 +142,10 @@ export default { default: false }, size: { - type: String, - default: 'medium' + validator (value) { + return ['small', 'medium', 'large'].includes(value) + }, + default: null }, filterable: { type: Boolean, diff --git a/src/DatePicker/src/DatePicker.vue b/src/DatePicker/src/DatePicker.vue index bf57bd081..e649334a5 100644 --- a/src/DatePicker/src/DatePicker.vue +++ b/src/DatePicker/src/DatePicker.vue @@ -14,7 +14,7 @@
@@ -265,7 +265,7 @@ export default { validator (value) { return ['small', 'medium', 'large'].includes(value) }, - default: 'medium' + default: null } }, provide () { @@ -289,7 +289,7 @@ export default { }, computed: { itemSize () { - return itemSize[this.size] || itemSize.medium + return itemSize[this.syntheticSize] || itemSize.medium }, valueToOptionMap () { const map = new Map() diff --git a/src/_mixins/asformitem.js b/src/_mixins/asformitem.js index b4ef0496e..6926e3fda 100644 --- a/src/_mixins/asformitem.js +++ b/src/_mixins/asformitem.js @@ -2,8 +2,19 @@ export default function (events = { change: 'change', blur: 'blur', focus: 'focus' -}) { +}, defaultSize = 'medium') { return { + computed: { + syntheticSize () { + const size = this.size + if (size) return size + const NFormItem = this.NFormItem + if (NFormItem && NFormItem.syntheticSize) { + return NFormItem.syntheticSize + } + return defaultSize + } + }, provide () { return { NFormItem: null