/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var tdesignIconsVue = require('tdesign-icons-vue');
var divider_index = require('../divider/index.js');
var config = require('../config.js');
var dropdown_dropdownItemProps = require('./dropdown-item-props.js');
var utils_classnames = require('../utils/classnames.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_event = require('../utils/event.js');
var utils_ripple = require('../utils/ripple.js');
require('../divider/divider.js');
require('../divider/props.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('@babel/runtime/helpers/typeof');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../utils/set-style.js');

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

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

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 name = "".concat(config.prefix, "-dropdown__item");
var _DropdownItem = Vue__default["default"].extend({
  name: "TDropdownItem",
  components: {
    TIconChevronRight: tdesignIconsVue.ChevronRightIcon,
    TDivider: divider_index.Divider
  },
  directives: {
    ripple: utils_ripple["default"]
  },
  inject: {
    dropdown: {
      "default": void 0
    }
  },
  props: _objectSpread(_objectSpread({}, dropdown_dropdownItemProps["default"]), {}, {
    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(tdesignIconsVue.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
        };
        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 = [name, (_ref = {}, _defineProperty__default["default"](_ref, "".concat(config.prefix, "-dropdown--suffix"), this.hasChildren), _defineProperty__default["default"](_ref, utils_classnames.STATUS_CLASSNAMES.disabled, this.disabled), _defineProperty__default["default"](_ref, utils_classnames.STATUS_CLASSNAMES.active, this.active), _ref)];
    return h("div", [h("div", {
      "directives": [{
        name: "ripple",
        value: true
      }],
      "class": classes,
      "on": {
        "click": this.handleItemClick,
        "mouseover": this.handleMouseover
      }
    }, [h("div", {
      "class": "".concat(name, "-content")
    }, [h("span", {
      "class": "".concat(name, "-text")
    }, [utils_renderTnode.renderContent(this, "content", "default")])]), this.renderSuffix()]), this.divider ? h(divider_index.Divider) : null]);
  }
});

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