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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
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('@babel/runtime/helpers/typeof');
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('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('../../chunks/set-style.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 = components_configProvider_configReceiver.getClassPrefixMixins("dropdown");
var 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: _objectSpread(_objectSpread({}, components_dropdown_props.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: iconsVue.ChevronRightIcon
      }),
          ChevronRightIcon = _this$useGlobalIcon.ChevronRightIcon;

      return this.hasChildren ? h(ChevronRightIcon, {
        "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
        };
        utils_event.emitEvent(this, "item-hover", this.path);
        utils_event.emitEvent(this, "click", data, {
          e: e
        });
        this.dropdown.handleMenuClick(data, {
          e: e
        });
      }
    },
    handleMouseover: function handleMouseover() {
      utils_event.emitEvent(this, "hover", this.path);
    }
  },
  render: function render() {
    var _ref;

    var h = arguments[0];
    var classes = ["".concat(this.componentName, "__item"), (_ref = {}, _defineProperty__default["default"](_ref, "".concat(this.componentName, "--suffix"), this.hasChildren), _defineProperty__default["default"](_ref, this.commonStatusClassName.disabled, this.disabled), _defineProperty__default["default"](_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")
    }, [utils_renderNode.renderContent(this, "content", "default")])]), this.renderSuffix()]), this.divider ? h(components_divider_index.Divider) : null]);
  }
});

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