/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var omit = require('lodash/omit');
var components_popup_index = require('../popup/index.js');
var hooks_useConfig = require('../../hooks/useConfig.js');
var hooks_lnode = require('../../hooks/lnode.js');
var components_dropdown_dropdownMenu = require('./dropdown-menu.js');
var components_dropdown_props = require('./props.js');
var components_dropdown_hooks_useDropdownOptions = require('./hooks/useDropdownOptions.js');
require('../../utils/map-props.js');
require('vue');
require('../../utils/withInstall.js');
require('lodash/capitalize');
require('../../config.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-fe796db6.js');
require('../../utils/easing.js');
require('../../utils/render-node.js');
require('lodash');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('../popup/props.js');
require('../popup/container.js');
require('../config-provider/useConfig.js');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/kebabCase');
require('../../hooks/render-lnode.js');
require('@ldesign/icons-vue');
require('../divider/index.js');
require('../divider/divider.js');
require('../divider/props.js');
require('../../hooks/useGlobalIcon.js');
require('./dropdown-item.js');
require('../../utils/ripple.js');
require('lodash/get');

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

var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);

var _Dropdown = VueCompositionAPI.defineComponent({
  name: "LDropdown",
  props: {
    ...components_dropdown_props.DropdownProps
  },
  setup(props2, _ref) {
    let {
      emit
    } = _ref;
    const dropdownClass = hooks_useConfig.usePrefixClass("dropdown");
    const isPopupVisible = VueCompositionAPI.ref(false);
    const handleMenuClick = (data, context) => {
      if (props2.hideAfterItemClick) {
        isPopupVisible.value = false;
        props2.popupProps?.onVisibleChange?.(false, context);
      }
      props2?.onClick?.(data, context);
      emit("click", data, context);
    };
    const handleVisibleChange = (visible, context) => {
      isPopupVisible.value = visible;
      props2.popupProps?.onVisibleChange?.(visible, context);
    };
    return {
      dropdownClass,
      handleMenuClick,
      isPopupVisible,
      handleVisibleChange
    };
  },
  render() {
    const h = arguments[0];
    const popupParams = {
      disabled: this.disabled,
      placement: this.placement,
      trigger: this.trigger,
      ...omit__default["default"](this.popupProps, "onVisibleChange"),
      overlayInnerClassName: [this.dropdownClass, this.popupProps?.overlayInnerClassName]
    };
    const renderTNodeJSX = hooks_lnode.useLNodeJSX();
    const options = components_dropdown_hooks_useDropdownOptions["default"](this.$props, this.$slots);
    const trigger = renderTNodeJSX("default")?.[0];
    return h(components_popup_index.Popup, {
      "props": {
        ...{
          destroyOnClose: true,
          visible: this.isPopupVisible,
          onVisibleChange: this.handleVisibleChange,
          expandAnimation: true,
          ...popupParams
        }
      }
    }, [h(components_dropdown_dropdownMenu["default"], {
      "slot": "content",
      "props": {
        ...{
          ...this.$props,
          options: options.value,
          onClick: this.handleMenuClick
        }
      }
    }), trigger]);
  }
});

exports["default"] = _Dropdown;
//# sourceMappingURL=dropdown.js.map
