<template>
  <ul class="uif-menu"><slot></slot></ul>
</template>
<script>
import {findChildComponents} from '@uif/core/lib/utils/findComponents'
import {forEach, includes} from '@uif/core/lib/utils/array'

export default {
  name: 'u-menu',
  props: {
    openNames: {
      type: Array,
      default () {
        return []
      }
    },
    accordion: {
      type: Boolean,
      default: false
    }
  },
  mounted () {
    forEach(findChildComponents(this, 'u-sub-menu', true), ref => {
      ref.accordion = this.accordion
      ref.active = includes(this.openNames, ref.name)
    })
  }
}
</script>
