Permalink
Browse files

feat(form controls): Optimize props (#604)

* [form-custom] create mixin

* [form-checkbox] optimise props

* [form-file] optimise props

* [form-input] optimize props

* [form-input-static] optimize props

* [form-radio] use form-custom mixin

* [form-select] use form-custom mixin

* [form mixin] remove non-common props
  • Loading branch information...
tmorehouse committed Jul 1, 2017
1 parent c2c200b commit 35a5db6e63f5e4bf9abac089c5bf680e7224959e
@@ -19,13 +19,14 @@

<script>
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
import formCheckBoxMixin from '../mixins/form-checkbox';
import arrayIncludes from '../utils/arrayIncludes';
import isArray from '../utils/isArray';
export default {
mixins: [formMixin, formCheckBoxMixin],
mixins: [formMixin, formCustomMixin, formCheckBoxMixin],
model: {
prop: 'checked',
event: 'change'
@@ -39,11 +40,18 @@ export default {
},
checked: {
default: true
},
size: {
type: String,
default: null
}
},
computed: {
isChecked() {
return arrayIncludes(this.checked, this.value);
},
custom() {
return !this.plain;
}
},
methods: {
@@ -83,9 +83,10 @@

<script>
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
export default {
mixins: [formMixin],
mixins: [formMixin, formCustomMixin],
data() {
return {
selectedFile: null,
@@ -23,6 +23,14 @@
},
formatter: {
type: Function
},
size: {
type: String,
default: null
},
state: {
type: String,
default: null
}
}
};
@@ -20,6 +20,8 @@
<b-form-input-static v-else
:id="id || null"
:value="value"
:size="size"
:state="state"
:formatter="formatter"
></b-form-input-static>
</template>
@@ -73,6 +75,14 @@
type: String,
default: 'text'
},
size: {
type: String,
default: null
},
state: {
type: String,
default: null
},
readonly: {
type: Boolean,
default: false
@@ -23,10 +23,11 @@
<script>
import formOptionsMixin from '../mixins/form-options';
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
import formCheckBoxMixin from '../mixins/form-checkbox';
export default {
mixins: [formMixin, formCheckBoxMixin, formOptionsMixin],
mixins: [formMixin, formCustomMixin, formCheckBoxMixin, formOptionsMixin],
data() {
return {
localValue: this.value
@@ -39,6 +40,14 @@
},
props: {
value: {},
size: {
type: String,
default: null
},
state: {
type: String,
default: null
},
options: {
type: [Array, Object],
default: null,
@@ -17,16 +17,21 @@
<script>
import formOptions from '../mixins/form-options';
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
export default {
mixins: [formMixin, formOptions],
mixins: [formMixin, formCustomMixin, formOptions],
data() {
return {
localValue: this.value
};
},
props: {
value: {},
size: {
type: String,
default: null
},
options: {
type: [Array, Object],
required: true
@@ -0,0 +1,13 @@
export default {
computed: {
custom() {
return !this.plain;
}
},
props: {
plain: {
type: Boolean,
default: false
}
}
};
@@ -5,30 +5,17 @@ export default {
this.size ? `form-control-${this.size}` : null,
this.state ? `form-control-${this.state}` : null
];
},
custom() {
return !this.plain;
}
},
props: {
name: {
type: String
},
disabled: {
type: Boolean
},
plain: {
type: Boolean,
default: false
},
state: {
type: String
},
size: {
type: String
},
id: {
type: String
},
disabled: {
type: Boolean
}
}
};

0 comments on commit 35a5db6

Please sign in to comment.