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

import { defineComponent, ref } from '@vue/composition-api';
import omit from 'lodash/omit';
import { Popup } from '../popup/index.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { useLNodeJSX } from '../../hooks/lnode.js';
import _DropdownMenu from './dropdown-menu.js';
import { DropdownProps } from './props.js';
import useDropdownOptions from './hooks/useDropdownOptions.js';
import '../../utils/map-props.js';
import 'vue';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import '../../config.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-fe796db6.js';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../popup/props.js';
import '../popup/container.js';
import '../popup/style/css.js';
import '../popup/type.js';
import '../config-provider/useConfig.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/kebabCase';
import '../../hooks/render-lnode.js';
import '@ldesign/icons-vue';
import '../divider/index.js';
import '../divider/divider.js';
import '../divider/props.js';
import '../divider/style/css.js';
import '../divider/type.js';
import '../../hooks/useGlobalIcon.js';
import './dropdown-item.js';
import '../../utils/ripple.js';
import 'lodash/get';

var _Dropdown = defineComponent({
  name: "LDropdown",
  props: {
    ...DropdownProps
  },
  setup(props2, _ref) {
    let {
      emit
    } = _ref;
    const dropdownClass = usePrefixClass("dropdown");
    const isPopupVisible = 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(this.popupProps, "onVisibleChange"),
      overlayInnerClassName: [this.dropdownClass, this.popupProps?.overlayInnerClassName]
    };
    const renderTNodeJSX = useLNodeJSX();
    const options = useDropdownOptions(this.$props, this.$slots);
    const trigger = renderTNodeJSX("default")?.[0];
    return h(Popup, {
      "props": {
        ...{
          destroyOnClose: true,
          visible: this.isPopupVisible,
          onVisibleChange: this.handleVisibleChange,
          expandAnimation: true,
          ...popupParams
        }
      }
    }, [h(_DropdownMenu, {
      "slot": "content",
      "props": {
        ...{
          ...this.$props,
          options: options.value,
          onClick: this.handleMenuClick
        }
      }
    }), trigger]);
  }
});

export { _Dropdown as default };
//# sourceMappingURL=dropdown.js.map
