<template>
  <div>
    <div class="text-left label"><label :for="`number-input-${getId}`">{{ title }}</label></div>
    <the-mask
      :id="`number-input-${getId}`"
      type="tel"
      :disabled="disabled"
      class="form-control radius-theme"
      mask="#########"
      :placeholder="placeHolder"
      v-model.trim="getCurrentValue"
    />
    <div class="text-left" v-show="error">
      <small class=" pt-2 text-danger" >Por favor, preencha este campo.</small>
    </div>
  </div>
   
</template>

<script>
export default {
  name: 'number-input',
  props: {
    numberInput: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      default: 'Número:',
    },
    placeHolder: {
      type: String,
      default: '987654321',
    },
    submit: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'numberInput',
    event: 'change',
  },
  computed: {
    error(){
      return this.submit && this.getCurrentValue.length == 0;
    },
    getCurrentValue: {
      get() {
        return this.numberInput;
      },
      set(value) {
        this.$emit('change', value);
      },
    },
    getId() {
      return Math.floor(Math.random() * 100);
    },
  },
};
</script>

<style scoped lang="scss">
@import '../../../assets/css/main.scss';
@import '../../../assets/css/cards.scss';
</style>
