<template>
  <div class="field">
    <label v-if="label.length" class="label is-small-mobile">{{ label }}</label>
    <div class="control">
      <textarea v-if="isTextarea" class="textarea is-small-mobile" :value="value" @input="input"></textarea>
      <input v-else :type="type" class="input is-small-mobile" :value="value" @input="input">
    </div>
  </div>
</template>

<script>

  export default {
    props: {
      label: {
        required: false,
        type: String,
        default: ""
      },
      value: {
        required: false,
        type: [String, Number],
        default: ""
      },
      type: {
        required: false,
        type: String,
        default: "text"
      }
    },

    computed: {
      isTextarea() {
        return this.type === "textarea";
      }
    },

    methods: {
      input(evt) {
        this.$emit("input", evt.target.value);
      }
    }
  }

</script>

<style lang="scss" scoped>
</style>