import { defineComponent, getCurrentInstance, ref, computed, provide, toRef, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createBlock, withCtx, createVNode, mergeProps } from 'vue';
import { PsButton } from '../../button/index.mjs';
import { PsIcon } from '../../icon/index.mjs';
import '../../../utils/index.mjs';
import { ArrowDown } from '@element-plus/icons-vue';
import '../../../hooks/index.mjs';
import { dropdownProps } from './dropdown.mjs';
import { DROPDOWN_INJECTION_KEY } from './tokens.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { addUnit } from '../../../utils/dom/style.mjs';
import { useSize } from '../../../hooks/use-common-props/index.mjs';

const { ButtonGroup: PsButtonGroup } = PsButton;
const _sfc_main = defineComponent({
  name: "PsDropdown",
  components: {
    PsButton,
    PsButtonGroup,
    PsIcon,
    ArrowDown
  },
  props: dropdownProps,
  emits: ["visible-change", "click", "command"],
  setup(props) {
    const _instance = getCurrentInstance();
    const ns = useNamespace("dropdown");
    const triggeringElementRef = ref();
    const referenceElementRef = ref();
    const popperRef = ref(null);
    const contentRef = ref(null);
    const scrollbar = ref(null);
    const currentTabId = ref(null);
    const isUsingKeyboard = ref(false);
    const wrapStyle = computed(() => ({
      maxHeight: addUnit(props.maxHeight)
    }));
    const dropdownTriggerKls = computed(() => [ns.m(dropdownSize.value)]);
    const dropdownSize = useSize();
    provide(DROPDOWN_INJECTION_KEY, {
      contentRef,
      isUsingKeyboard
    });
    provide("elDropdown", {
      instance: _instance,
      dropdownSize,
      trigger: toRef(props, "trigger"),
      hideOnClick: toRef(props, "hideOnClick")
    });
    return {
      ns,
      scrollbar,
      wrapStyle,
      dropdownTriggerKls,
      dropdownSize,
      currentTabId,
      popperRef,
      triggeringElementRef,
      referenceElementRef
    };
  }
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_ps_button = resolveComponent("ps-button");
  const _component_arrow_down = resolveComponent("arrow-down");
  const _component_ps_icon = resolveComponent("ps-icon");
  const _component_ps_button_group = resolveComponent("ps-button-group");
  return openBlock(), createElementBlock("div", {
    class: normalizeClass([_ctx.ns.b(), _ctx.ns.is("disabled", _ctx.disabled)])
  }, [
    !_ctx.splitButton ? (openBlock(), createElementBlock("div", {
      key: 0,
      class: normalizeClass(_ctx.dropdownTriggerKls)
    }, [
      renderSlot(_ctx.$slots, "default")
    ], 2)) : createCommentVNode("v-if", true),
    _ctx.splitButton ? (openBlock(), createBlock(_component_ps_button_group, { key: 1 }, {
      default: withCtx(() => [
        createVNode(_component_ps_button, mergeProps({ ref: "referenceElementRef" }, _ctx.buttonProps, {
          size: _ctx.dropdownSize,
          type: _ctx.type,
          disabled: _ctx.disabled
        }), {
          default: withCtx(() => [
            renderSlot(_ctx.$slots, "default")
          ]),
          _: 3
        }, 16, ["size", "type", "disabled"]),
        createVNode(_component_ps_button, mergeProps({ ref: "triggeringElementRef" }, _ctx.buttonProps, {
          size: _ctx.dropdownSize,
          type: _ctx.type,
          class: _ctx.ns.e("caret-button"),
          disabled: _ctx.disabled
        }), {
          default: withCtx(() => [
            createVNode(_component_ps_icon, {
              class: normalizeClass(_ctx.ns.e("icon"))
            }, {
              default: withCtx(() => [
                createVNode(_component_arrow_down)
              ]),
              _: 1
            }, 8, ["class"])
          ]),
          _: 1
        }, 16, ["size", "type", "class", "disabled"])
      ]),
      _: 3
    })) : createCommentVNode("v-if", true)
  ], 2);
}
var Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/meng/workspace/element-ps/packages/components/dropdown/src/dropdown.vue"]]);

export { Dropdown as default };
//# sourceMappingURL=dropdown2.mjs.map
