<commit_before><template lang="pug">
ul.md-nav-tabs.nav.nav-tabs(role='tablist')
  nav-tab(v-if='!hasDefaultSlot' v-for='t in tabs', :key='t', :id='t.id', :name='t.name', :active='t.active', :icon='t.icon' @onTabClick='onTabClick')
  slot
</template>

<script>
import NavTab from './nav-tab'
import { EVENT_ON_TAB_CLICK } from './constants'

export default {
  name: 'nav-tabs',
  props: {
    tabs: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  components: {
    NavTab
  },
  computed: {
    hasDefaultSlot() {
      return !!this.$slots.default
    }
  },
  methods: {
    onTabClick(tabId) {
      let tab = this.tabs.find(t => t.id === tabId)
      tab.active = true
      this.tabs.forEach((tab) => {
        if (tab.id === tabId) {
          tab.active = true
          this.$emit(EVENT_ON_TAB_CLICK, tab || tabId)
        } else {
          tab.active = false
        }
      }, this)
    }
  }
}
</script>

<style lang="scss"></style>
<commit_msg>Use :key='tab.id' instead of tab<commit_after><template lang="pug">
ul.md-nav-tabs.nav.nav-tabs(role='tablist')
  nav-tab(v-if='!hasDefaultSlot' v-for='t in tabs', :key='t.id', :id='t.id', :name='t.name', :active='t.active', :icon='t.icon' @onTabClick='onTabClick')
  slot
</template>

<script>
import NavTab from './nav-tab'
import { EVENT_ON_TAB_CLICK } from './constants'

export default {
  name: 'nav-tabs',
  props: {
    tabs: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  components: {
    NavTab
  },
  computed: {
    hasDefaultSlot() {
      return !!this.$slots.default
    }
  },
  methods: {
    onTabClick(tabId) {
      let tab = this.tabs.find(t => t.id === tabId)
      tab.active = true
      this.tabs.forEach((tab) => {
        if (tab.id === tabId) {
          tab.active = true
          this.$emit(EVENT_ON_TAB_CLICK, tab || tabId)
        } else {
          tab.active = false
        }
      }, this)
    }
  }
}
</script>

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

{'fraction_non_alphanumeric': 0.18725099601593626, 'fraction_numerical': 0.0, 'mean_word_length': 2.3097199341021417, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '807897', 'n_tokens_mistral': 749, 'n_tokens_neox': 746, 'n_words': 134}