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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var iconsVue = require('@ldesign/icons-vue');
var components_divider_index = require('../divider/index.js');
var components_dropdown_props = require('./props.js');
var utils_renderNode = require('../../utils/render-node.js');
var utils_event = require('../../utils/event.js');
var utils_ripple = require('../../utils/ripple.js');
var utils_mixins = require('../../utils/mixins.js');
var components_configProvider_configReceiver = require('../config-provider/config-receiver.js');
require('../divider/divider.js');
require('../divider/props.js');
require('vue');
require('lodash/camelCase');
require('lodash/kebabCase');
require('lodash/mergeWith');
require('lodash');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/with-install.js');
require('../../config.js');
require('../../utils/helper.js');
require('../../chunks/set-style.js');

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

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

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

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

    handleMouseover() {
      utils_event.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`
    }, [utils_renderNode.renderContent(this, "content", "default")])]), this.renderSuffix()]), this.divider ? h(components_divider_index.Divider) : null]);
  }

});

exports["default"] = _DropdownItem;
//# sourceMappingURL=dropdown-item.js.map
