2016-11-14 05:33:04 +00:00
|
|
|
export default {
|
|
|
|
|
props: {
|
2016-11-16 00:50:16 +00:00
|
|
|
value: [String, Number],
|
2016-11-14 05:33:04 +00:00
|
|
|
disabled: Boolean,
|
|
|
|
|
required: Boolean,
|
2016-11-14 20:53:06 +00:00
|
|
|
maxlength: [Number, String],
|
|
|
|
|
placeholder: String
|
2016-11-14 05:33:04 +00:00
|
|
|
},
|
|
|
|
|
watch: {
|
2016-11-14 05:39:16 +00:00
|
|
|
value() {
|
|
|
|
|
this.setParentValue();
|
|
|
|
|
},
|
2016-11-14 05:33:04 +00:00
|
|
|
disabled() {
|
|
|
|
|
this.setParentDisabled();
|
|
|
|
|
},
|
|
|
|
|
required() {
|
|
|
|
|
this.setParentRequired();
|
|
|
|
|
},
|
|
|
|
|
placeholder() {
|
|
|
|
|
this.setParentPlaceholder();
|
|
|
|
|
},
|
|
|
|
|
maxlength() {
|
|
|
|
|
this.handleMaxLength();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
handleMaxLength() {
|
|
|
|
|
this.parentContainer.enableCounter = this.maxlength > 0;
|
|
|
|
|
this.parentContainer.counterLength = this.maxlength;
|
|
|
|
|
},
|
|
|
|
|
setParentValue() {
|
|
|
|
|
this.parentContainer.setValue(this.$el.value);
|
|
|
|
|
},
|
|
|
|
|
setParentDisabled() {
|
|
|
|
|
this.parentContainer.isDisabled = this.disabled;
|
|
|
|
|
},
|
|
|
|
|
setParentRequired() {
|
|
|
|
|
this.parentContainer.isRequired = this.required;
|
|
|
|
|
},
|
|
|
|
|
setParentPlaceholder() {
|
|
|
|
|
this.parentContainer.hasPlaceholder = !!this.placeholder;
|
|
|
|
|
},
|
|
|
|
|
onFocus() {
|
|
|
|
|
this.parentContainer.isFocused = true;
|
|
|
|
|
},
|
|
|
|
|
onBlur() {
|
|
|
|
|
this.parentContainer.isFocused = false;
|
|
|
|
|
this.setParentValue();
|
|
|
|
|
},
|
|
|
|
|
onInput() {
|
|
|
|
|
this.setParentValue();
|
|
|
|
|
this.parentContainer.inputLength = this.$el.value.length;
|
|
|
|
|
this.$emit('change', this.$el.value);
|
|
|
|
|
this.$emit('input', this.$el.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|