/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 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/use-config.js';
import { useLNodeJSX } from '../../hooks/lnode.js';
import _DropdownMenu from './dropdown-menu.js';
import { DropdownProps } from './props.js';
import useDropdownOptions from './hooks/use-dropdown-options.js';
import '../../utils/map-props.js';
import 'vue';
import '../../utils/with-install.js';
import 'lodash';
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-2e6815bd.js';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
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';
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';
import '../divider/type.js';
import '../../hooks/use-global-icon.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) => {
      var _props2$onClick;
      if (props2.hideAfterItemClick) {
        var _props2$popupProps, _props2$popupProps$on;
        isPopupVisible.value = false;
        (_props2$popupProps = props2.popupProps) === null || _props2$popupProps === void 0 ? void 0 : (_props2$popupProps$on = _props2$popupProps.onVisibleChange) === null || _props2$popupProps$on === void 0 ? void 0 : _props2$popupProps$on.call(_props2$popupProps, false, context);
      }
      props2 === null || props2 === void 0 ? void 0 : (_props2$onClick = props2.onClick) === null || _props2$onClick === void 0 ? void 0 : _props2$onClick.call(props2, data, context);
      emit("click", data, context);
    };
    const handleVisibleChange = (visible, context) => {
      var _props2$popupProps2, _props2$popupProps2$o;
      isPopupVisible.value = visible;
      (_props2$popupProps2 = props2.popupProps) === null || _props2$popupProps2 === void 0 ? void 0 : (_props2$popupProps2$o = _props2$popupProps2.onVisibleChange) === null || _props2$popupProps2$o === void 0 ? void 0 : _props2$popupProps2$o.call(_props2$popupProps2, visible, context);
    };
    return {
      dropdownClass,
      handleMenuClick,
      isPopupVisible,
      handleVisibleChange
    };
  },
  render() {
    var _this$popupProps, _renderTNodeJSX;
    const h = arguments[0];
    const popupParams = {
      disabled: this.disabled,
      placement: this.placement,
      trigger: this.trigger,
      ...omit(this.popupProps, "onVisibleChange"),
      overlayInnerClassName: [this.dropdownClass, (_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.overlayInnerClassName]
    };
    const renderTNodeJSX = useLNodeJSX();
    const options = useDropdownOptions(this.$props, this.$slots);
    const trigger = (_renderTNodeJSX = renderTNodeJSX("default")) === null || _renderTNodeJSX === void 0 ? void 0 : _renderTNodeJSX[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
