/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { ChevronRightIcon } from 'tdesign-icons-vue';
import { Divider } from '../divider/index.js';
import { prefix } from '../config.js';
import itemProps from './dropdown-item-props.js';
import { STATUS_CLASSNAMES } from '../utils/classnames.js';
import { renderContent } from '../utils/render-tnode.js';
import { emitEvent } from '../utils/event.js';
import Ripple from '../utils/ripple.js';
import mixins from '../utils/mixins.js';
import { getKeepAnimationMixins } from '../config-provider/config-receiver.js';
import '../divider/divider.js';
import 'vue';
import '../divider/props.js';
import '@babel/runtime/helpers/typeof';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../divider/type.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../_common/js/utils/set-style.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.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 name = "".concat(prefix, "-dropdown__item");
var keepAnimationMixins = getKeepAnimationMixins();
var _DropdownItem = mixins(keepAnimationMixins).extend({
  name: "TDropdownItem",
  components: {
    ChevronRightIcon: ChevronRightIcon,
    TDivider: Divider
  },
  directives: {
    ripple: Ripple
  },
  inject: {
    dropdown: {
      "default": void 0
    }
  },
  props: _objectSpread(_objectSpread({}, itemProps), {}, {
    path: {
      type: String,
      "default": ""
    },
    hasChildren: {
      type: Boolean,
      "default": false
    }
  }),
  data: function data() {
    return {
      focused: false
    };
  },
  methods: {
    renderSuffix: function renderSuffix() {
      var h = this.$createElement;
      return this.hasChildren ? h(ChevronRightIcon, {
        "class": "".concat(name, "-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 = [name, (_ref = {}, _defineProperty(_ref, "".concat(prefix, "-dropdown--suffix"), this.hasChildren), _defineProperty(_ref, STATUS_CLASSNAMES.disabled, this.disabled), _defineProperty(_ref, STATUS_CLASSNAMES.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(name, "-content")
    }, [h("span", {
      "class": "".concat(name, "-text")
    }, [renderContent(this, "content", "default")])]), this.renderSuffix()]), this.divider ? h(Divider) : null]);
  }
});

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