<template>
  <t-textarea
    v-model="valueData"
    :disabled="!config.writable"
    @change="emitChange"
  ></t-textarea>
</template>
<script setup name="TEXTAREA">
import { ref, watch } from 'vue';
const props = defineProps({
  config: { type: Object },
  modelValue: { type: String },
});
const emit = defineEmits(['update:modelValue', 'change']);

const valueData = ref('');

const emitChange = () => {
  emit('update:modelValue', valueData.value);
  emit('change', valueData.value);
};

watch(
  () => props.modelValue,
  (val, oldval) => {
    if (val === oldval) return;
    valueData.value = val;
  },
  {
    immediate: true,
  }
);
</script>
