2016-08-01 05:45:40 +00:00
|
|
|
<template>
|
|
|
|
|
<input
|
|
|
|
|
class="md-input"
|
2016-11-14 05:33:04 +00:00
|
|
|
:type="type"
|
2016-09-18 14:46:50 +00:00
|
|
|
:value="value"
|
2016-08-01 05:45:40 +00:00
|
|
|
:disabled="disabled"
|
2016-08-02 05:35:33 +00:00
|
|
|
:required="required"
|
|
|
|
|
:placeholder="placeholder"
|
2016-09-19 03:45:48 +00:00
|
|
|
:maxlength="maxlength"
|
2016-08-01 05:45:40 +00:00
|
|
|
@focus="onFocus"
|
|
|
|
|
@blur="onBlur"
|
2016-09-18 14:46:50 +00:00
|
|
|
@input="onInput"
|
|
|
|
|
@keydown.up="onInput"
|
|
|
|
|
@keydown.down="onInput">
|
2016-08-01 05:45:40 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2016-11-14 05:33:04 +00:00
|
|
|
import common from './common';
|
|
|
|
|
import getClosestVueParent from '../../core/utils/getClosestVueParent';
|
2016-08-02 05:05:32 +00:00
|
|
|
|
2016-08-01 05:45:40 +00:00
|
|
|
export default {
|
2016-11-14 05:33:04 +00:00
|
|
|
mixins: [common],
|
2016-08-01 05:45:40 +00:00
|
|
|
props: {
|
2016-11-14 05:33:04 +00:00
|
|
|
type: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'text'
|
2016-08-01 05:45:40 +00:00
|
|
|
}
|
|
|
|
|
},
|
2016-08-31 22:20:23 +00:00
|
|
|
mounted() {
|
2016-11-14 05:33:04 +00:00
|
|
|
this.parentContainer = getClosestVueParent(this.$parent, 'md-input-container');
|
|
|
|
|
|
|
|
|
|
if (!this.parentContainer) {
|
2016-08-02 04:20:35 +00:00
|
|
|
this.$destroy();
|
|
|
|
|
|
|
|
|
|
throw new Error('You should wrap the md-input in a md-input-container');
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 05:33:04 +00:00
|
|
|
this.setParentDisabled();
|
|
|
|
|
this.setParentRequired();
|
|
|
|
|
this.setParentPlaceholder();
|
|
|
|
|
this.setParentValue();
|
|
|
|
|
this.handleMaxLength();
|
2016-08-01 05:45:40 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|