<script setup lang="ts">
import { ref } from 'vue';

const { value: inputValue } = defineProps(['value']);
const emit = defineEmits(['submit', 'update:value']);

</script>

<template>
    <McInput
      :value="inputValue"
      :maxLength="2000"
      @change="(newValue: string) => emit('update:value', newValue)"
      @submit="emit('submit', inputValue)"
    >
      <template #extra>
        <div class="input-foot-wrapper">
          <div class="input-foot-left">
            <span class="input-foot-dividing-line"></span>
            <span class="input-foot-maxlength">{{ inputValue.length }}/2000</span>
          </div>
          <div class="input-foot-right">
            <d-button 
              icon="op-clearup" 
              shape="round" 
              :disabled="!inputValue" 
              @click="emit('update:value', '')"
            >
              清空输入
            </d-button>
          </div>
        </div>
      </template>
    </McInput>
</template>