<template>
    <el-input
        v-model="inputValue"
        :placeholder="placeholder"
        :clearable="clearable"
        :disabled="disabled"
        :size="size"
        :style="style"
        v-bind="$attrs"
        @keyup.enter="handleEnter"
    />
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
    modelValue: {
        type: [String, Number],
        default: '',
    },
    placeholder: {
        type: String,
        default: '请输入',
    },
    clearable: {
        type: Boolean,
        default: true,
    },
    disabled: {
        type: Boolean,
        default: false,
    },
    size: {
        type: String,
        default: 'default',
    },
    style: {
        type: Object,
        default: () => ({ width: '180px' }),
    },
})

const emit = defineEmits(['update:modelValue', 'enter'])

const inputValue = computed({
    get: () => props.modelValue,
    set: (val) => emit('update:modelValue', val),
})

const handleEnter = () => {
    emit('enter')
}
</script>
