<template>
  <li
    class="xb-dropdown-menu__item"
    :class="{
      'is-disabled': disabled,
      'xb-dropdown-menu__item--divided': divided,
      'is-select': selected
    }"
    @click="handleClick"
    :aria-disabled="disabled"
    :tabindex="disabled ? null : -1"
  >
    <i :class="icon" v-if="icon"></i>
    <slot></slot>
  </li>
</template>
<script>
  import Emitter from 'xinbao-ui/src/mixins/emitter';

  export default {
    name: 'XbDropdownItem',

    mixins: [Emitter],

    props: {
      command: {},
      disabled: Boolean,
      selected: Boolean,
      divided: Boolean,
      icon: String
    },

    methods: {
      handleClick(e) {
        this.dispatch('XbDropdown', 'menu-item-click', [this.command, this]);
      }
    }
  };
</script>
