<template>
  <div class="tw-flex tw-flex-col">
    <select :class="['tw-pr-[40px]', validation ? '' : 'tw-border-error-default']" v-model="value" @change="inputVal">
      <option v-for="(name, index) in yearList" :key="index">
        {{ name }}
      </option>
    </select>
  </div>
</template>
<script>
export default {
  name: "ElementSelect",
  props: {
    select: {
      type: Object,
    },
    yearList: {
      type: Array,
    },
    default: {
      type: String,
    },
    validation: {
      type: Boolean,
    },
  },
  data() {
    return {
      value: this.default ?? null,
    };
  },
  mounted() { },
  watch: {
    default: {
      handler: function () {
        this.value = this.default;
      },
    },
  },
  methods: {
    inputVal() {
      this.$emit("change", this.value);
    },
  },
};
</script>
<style lang="scss" scoped>
select {
  -moz-appearance: none;
  /* Firefox */
  -webkit-appearance: none;
  /* Safari and Chrome */
  appearance: none;
  background-image: url("~/assets/svg/down-arrow.svg");
  background-size: 9px 6px;
  background-position: right 20px center;
  background-repeat: no-repeat;
}
</style>
