export default {
  name: 'BaseTabs',
  props: {
    options: {
      type: Array,
    },
    full: {
      type: Boolean,
      default: false,
    },
    vertical: {
      type: Boolean,
      default: false,
    },
  },
  created() {
    this.oneActive();
  },
  updated() {
    this.oneActive();
  },
  methods: {
    oneActive(){
      const hasItemActive = this.options.find(item => item.active);
      if (!hasItemActive && this.options.length) {
        this.onClickTab(0);
      }
    },
    onClickTab(optionIndex) {
      const options = this.options.map((option, index) => {
        if (optionIndex == index) {
          option.active = true;
        } else {
          option.active = false;
        }
        return option;
      });

      this.$emit('click-tab', options);
    },
  },
};
