<template>
  <div class="ipub-menus">
    <slot>
      <div class="ipub-menus__item"
           v-for="item in menus"
           :key="'ipub-menus'+(item.key || item.code || item.href || item.name || item.toString())">
        <ipub-menus-item :nameLabel="nameLabel"
                         :hrefLabel="hrefLabel"
                         :type="type"
                         :item="item"></ipub-menus-item>
      </div>
    </slot>
  </div>
</template>

<script>
import IpubMenusItem from './item'
export default {
  name: 'IpubMenus',
  components: {
    IpubMenusItem
  },
  props: {
    menus: {
      type: Array,
      default () {
        return []
      }
    },
    type: {
      type: String,
      default: 'theme',
      validator (val) {
        return ['default', 'link', 'theme', 'danger', 'warning', 'success'].indexOf(val) !== -1
      }
    },
    nameLabel: {
      type: String,
      default: 'name'
    },
    hrefLabel: {
      type: String,
      default: 'href'
    },
  }
}
</script>

