<template>
  <t-input-number
    v-model="valueData"
    theme="normal"
    :disabled="!config.writable"
    style="width: 100%"
    @change="emitChange"
  ></t-input-number>
</template>
<script setup name="NUMBER">
import { ref, watch } from 'vue';
const props = defineProps({
  config: { type: Object },
  modelValue: { type: Number },
});
const emit = defineEmits(['update:modelValue', 'change']);

const valueData = ref(null);

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

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