/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
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 { useTNodeJSX } from '../hooks/tnode.js';
import _DropdownMenu from './dropdown-menu.js';
import props from './props.js';
import useDropdownOptions from './hooks/useDropdownOptions.js';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'vue';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/helper.js';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/utils/set-style.js';
import '../config-provider/config-receiver.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 '../_chunks/dep-2cb61c79.js';
import 'dayjs';
import '../utils/mixins.js';
import '../utils/event.js';
import '../popup/props.js';
import '../popup/container.js';
import 'lodash/isFunction';
import '../popup/utils.js';
import '../popup/trigger.js';
import '../popup/plugin.js';
import '../config-provider/useConfig.js';
import 'lodash/isEmpty';
import '../hooks/render-tnode.js';
import 'lodash/isObject';
import '@ldesign/icons-vue';
import '../divider/index.js';
import '../divider/divider.js';
import '../divider/props.js';
import '../hooks/useGlobalIcon.js';
import './dropdown-item.js';
import '../utils/ripple.js';
import '../config.js';
import './dropdown-item-props.js';
import 'lodash/get';

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 _Dropdown = defineComponent({
  name: "TDropdown",
  props: _objectSpread({}, props),
  setup: function setup(props2, _ref) {
    var emit = _ref.emit;
    var dropdownClass = usePrefixClass("dropdown");
    var isPopupVisible = ref(false);
    var handleMenuClick = function handleMenuClick(data, context) {
      var _props2$onClick;
      if (props2.hideAfterItemClick) {
        var _props2$popupProps, _props2$popupProps$on, _props2$popupProps2, _props2$popupProps2$o;
        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$popupProps2 = props2.popupProps) === null || _props2$popupProps2 === void 0 ? void 0 : (_props2$popupProps2$o = _props2$popupProps2["on-visible-change"]) === null || _props2$popupProps2$o === void 0 ? void 0 : _props2$popupProps2$o.call(_props2$popupProps2, 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);
    };
    var handleVisibleChange = function handleVisibleChange(visible, context) {
      var _props2$popupProps3, _props2$popupProps3$o, _props2$popupProps4, _props2$popupProps4$o;
      isPopupVisible.value = visible;
      (_props2$popupProps3 = props2.popupProps) === null || _props2$popupProps3 === void 0 ? void 0 : (_props2$popupProps3$o = _props2$popupProps3.onVisibleChange) === null || _props2$popupProps3$o === void 0 ? void 0 : _props2$popupProps3$o.call(_props2$popupProps3, visible, context);
      (_props2$popupProps4 = props2.popupProps) === null || _props2$popupProps4 === void 0 ? void 0 : (_props2$popupProps4$o = _props2$popupProps4["on-visible-change"]) === null || _props2$popupProps4$o === void 0 ? void 0 : _props2$popupProps4$o.call(_props2$popupProps4, visible, context);
    };
    return {
      dropdownClass: dropdownClass,
      handleMenuClick: handleMenuClick,
      isPopupVisible: isPopupVisible,
      handleVisibleChange: handleVisibleChange
    };
  },
  render: function render() {
    var _this$popupProps, _renderTNodeJSX;
    var h = arguments[0];
    var popupParams = _objectSpread(_objectSpread({
      disabled: this.disabled,
      placement: this.placement,
      trigger: this.trigger
    }, omit(this.popupProps, ["onVisibleChange", "on-visible-change"])), {}, {
      overlayInnerClassName: [this.dropdownClass, (_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.overlayInnerClassName]
    });
    var renderTNodeJSX = useTNodeJSX();
    var options = useDropdownOptions(this.$props, this.$slots);
    var trigger = (_renderTNodeJSX = renderTNodeJSX("default")) === null || _renderTNodeJSX === void 0 ? void 0 : _renderTNodeJSX[0];
    return h(Popup, {
      "props": _objectSpread({}, _objectSpread({
        destroyOnClose: true,
        visible: this.isPopupVisible,
        onVisibleChange: this.handleVisibleChange,
        expandAnimation: true
      }, popupParams))
    }, [h(_DropdownMenu, {
      "slot": "content",
      "props": _objectSpread({}, _objectSpread(_objectSpread({}, this.$props), {}, {
        options: options.value,
        onClick: this.handleMenuClick
      }))
    }), trigger]);
  }
});

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