<template>
    <div :class="className">
        <el-input v-model="curValue" :placeholder="placeholder"></el-input>
    </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';

@Component({})
export default class AppPresetTextInput extends Vue {
    /**
     * 输入值
     *
     * @type {*}
     * @memberof AppPresetTextInput
     */
    @Prop() public value!: any;

    /**
     * 名称
     *
     * @type {string}
     * @memberof AppPresetTextInput
     */
    @Prop() public name!: string;

    /**
     * 禁用
     *
     * @type {boolean}
     * @memberof AppPresetTextInput
     */
    @Prop() public disabled?: boolean;

    /**
     * 占位文本
     *
     * @type {string}
     * @memberof AppPresetTextInput
     */
    @Prop({default: ''}) public placeholder?: string;

    /**
     * 类名
     *
     * @memberof AppPresetSwitch
     */
    get className(): string {
        return `app-preset-text-input ${this.name}`;
    }

    /**
     * 当前值
     *
     * @memberof AppPresetTextInput
     */
    get curValue() {
        return this.value;
    }

    /**
     * 值变化
     *
     * @memberof AppPresetTextInput
     */
    set curValue(val: any) {
        this.$emit('valueChange', { name: this.name, value: val });
    }
}
</script>

<style lang='less'>
@import './app-preset-text-input.less';
</style>