/**
 * ldesign v0.2.3
 * (c) 2022年9月24日 swimly
 * @license MIT
 */

import { ChevronRightIcon } from '@ldesign/icons-vue';
import { Divider } from '../divider/index.js';
import { DropdownItemProps } from './props.js';
import { renderContent } from '../../utils/render-node.js';
import { emitEvent } from '../../utils/event.js';
import Ripple from '../../utils/ripple.js';
import mixins from '../../utils/mixins.js';
import { getClassPrefixMixins, getKeepAnimationMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js';
import '../divider/divider.js';
import '../divider/props.js';
import 'vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../divider/style/css.js';
import '../divider/type.js';
import '../../utils/helper.js';
import '../../chunks/set-style.js';

const classPrefixMixins = getClassPrefixMixins("dropdown");
const keepAnimationMixins = getKeepAnimationMixins();
var _DropdownItem = mixins(keepAnimationMixins, classPrefixMixins, getGlobalIconMixins()).extend({
  name: "LDropdownItem",
  components: {
    TDivider: Divider
  },
  directives: {
    ripple: Ripple
  },
  inject: {
    dropdown: {
      default: void 0
    }
  },
  props: { ...DropdownItemProps,
    path: {
      type: String,
      default: ""
    },
    hasChildren: {
      type: Boolean,
      default: false
    }
  },

  data() {
    return {
      focused: false
    };
  },

  methods: {
    renderSuffix() {
      const h = this.$createElement;
      const {
        ChevronRightIcon: ChevronRightIcon$1
      } = this.useGlobalIcon({
        ChevronRightIcon: ChevronRightIcon
      });
      return this.hasChildren ? h(ChevronRightIcon$1, {
        "class": `${this.componentName}__item-icon`
      }) : null;
    },

    handleItemClick(e) {
      if (!this.hasChildren && !this.disabled) {
        const data = {
          value: this.value,
          path: this.path,
          content: this.content
        };
        emitEvent(this, "item-hover", this.path);
        emitEvent(this, "click", data, {
          e
        });
        this.dropdown.handleMenuClick(data, {
          e
        });
      }
    },

    handleMouseover() {
      emitEvent(this, "hover", this.path);
    }

  },

  render() {
    const h = arguments[0];
    const classes = [`${this.componentName}__item`, {
      [`${this.componentName}--suffix`]: this.hasChildren,
      [this.commonStatusClassName.disabled]: this.disabled,
      [this.commonStatusClassName.active]: this.active
    }];
    return h("div", [h("div", {
      "directives": [{
        name: "ripple",
        value: this.keepAnimation.ripple
      }],
      "class": classes,
      "on": {
        "click": this.handleItemClick,
        "mouseover": this.handleMouseover
      }
    }, [h("div", {
      "class": `${this.componentName}__item-content`
    }, [h("span", {
      "class": `${this.componentName}__item-text`
    }, [renderContent(this, "content", "default")])]), this.renderSuffix()]), this.divider ? h(Divider) : null]);
  }

});

export { _DropdownItem as default };
//# sourceMappingURL=dropdown-item.js.map
