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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
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 '@babel/runtime/helpers/typeof';
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';
import '../divider/type.js';
import '../../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../../chunks/set-style.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var classPrefixMixins = getClassPrefixMixins("dropdown");
var keepAnimationMixins = getKeepAnimationMixins();
var _DropdownItem = mixins(keepAnimationMixins, classPrefixMixins, getGlobalIconMixins()).extend({
  name: "LDropdownItem",
  components: {
    TDivider: Divider
  },
  directives: {
    ripple: Ripple
  },
  inject: {
    dropdown: {
      "default": void 0
    }
  },
  props: _objectSpread(_objectSpread({}, DropdownItemProps), {}, {
    path: {
      type: String,
      "default": ""
    },
    hasChildren: {
      type: Boolean,
      "default": false
    }
  }),
  data: function data() {
    return {
      focused: false
    };
  },
  methods: {
    renderSuffix: function renderSuffix() {
      var h = this.$createElement;

      var _this$useGlobalIcon = this.useGlobalIcon({
        ChevronRightIcon: ChevronRightIcon
      }),
          ChevronRightIcon$1 = _this$useGlobalIcon.ChevronRightIcon;

      return this.hasChildren ? h(ChevronRightIcon$1, {
        "class": "".concat(this.componentName, "__item-icon")
      }) : null;
    },
    handleItemClick: function handleItemClick(e) {
      if (!this.hasChildren && !this.disabled) {
        var data = {
          value: this.value,
          path: this.path,
          content: this.content
        };
        emitEvent(this, "item-hover", this.path);
        emitEvent(this, "click", data, {
          e: e
        });
        this.dropdown.handleMenuClick(data, {
          e: e
        });
      }
    },
    handleMouseover: function handleMouseover() {
      emitEvent(this, "hover", this.path);
    }
  },
  render: function render() {
    var _ref;

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

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