import { defineComponent, ref, computed, resolveComponent, createBlock, openBlock, mergeProps, unref, withCtx, createVNode, createElementVNode, normalizeClass, renderSlot, createCommentVNode, normalizeProps, guardReactiveProps, toDisplayString, createElementBlock, Fragment, renderList, withModifiers } from 'vue';
import '../../../utils/index.mjs';
import { defaultButtonProps, dropdownButtonSimpleEmits, dropdownButtonSimpleProps } from './dropdown-button-simple.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlDropdownButtonSimple" },
  __name: "dropdown-button-simple",
  props: dropdownButtonSimpleProps,
  emits: dropdownButtonSimpleEmits,
  setup(__props, { emit: __emit }) {
    const bem = createNamespace("dropdown-button-simple");
    const props = __props;
    const emits = __emit;
    const dropdownOpen = ref(false);
    const computedButtonProps = computed(() => ({
      ...defaultButtonProps,
      ...props.buttonProps
    }));
    const handleMenuItemClick = (item) => {
      emits("clickItem", item);
    };
    const handleDropdownOpenChange = (open) => {
      dropdownOpen.value = open;
    };
    const handleDropdownClick = () => {
      dropdownOpen.value = false;
    };
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_ll_button = resolveComponent("ll-button");
      const _component_a_menu_item = resolveComponent("a-menu-item");
      const _component_a_menu = resolveComponent("a-menu");
      const _component_a_dropdown = resolveComponent("a-dropdown");
      return openBlock(), createBlock(_component_a_dropdown, mergeProps({ open: dropdownOpen.value }, _ctx.dropDownProps, {
        disabled: _ctx.disabled,
        class: unref(bem).b(),
        onOpenChange: handleDropdownOpenChange
      }), {
        overlay: withCtx(() => [
          createVNode(_component_a_menu, { onClick: handleDropdownClick }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(
                Fragment,
                null,
                renderList(_ctx.dropdownItems, (item, index) => {
                  return openBlock(), createBlock(_component_a_menu_item, {
                    key: item?.key ?? index,
                    disabled: item.disabled || props.disabled,
                    onClick: withModifiers(($event) => handleMenuItemClick(item), ["stop"])
                  }, {
                    default: withCtx(() => [
                      renderSlot(_ctx.$slots, "menuItem", mergeProps({ ref_for: true }, item), () => [
                        createElementVNode(
                          "div",
                          {
                            class: normalizeClass(unref(bem).m("icon-box"))
                          },
                          [
                            item.iconProps ? (openBlock(), createBlock(
                              _component_ll_icon,
                              mergeProps({
                                key: 0,
                                ref_for: true
                              }, item.iconProps),
                              null,
                              16
                              /* FULL_PROPS */
                            )) : createCommentVNode("v-if", true),
                            createElementVNode(
                              "span",
                              null,
                              toDisplayString(item ? item.label : "-"),
                              1
                              /* TEXT */
                            )
                          ],
                          2
                          /* CLASS */
                        )
                      ])
                    ]),
                    _: 2
                    /* DYNAMIC */
                  }, 1032, ["disabled", "onClick"]);
                }),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 3
            /* FORWARDED */
          })
        ]),
        default: withCtx(() => [
          createVNode(_component_ll_button, mergeProps(computedButtonProps.value, { disabled: _ctx.disabled }), {
            default: withCtx(() => [
              createElementVNode(
                "div",
                {
                  class: normalizeClass(unref(bem).m("icon-box"))
                },
                [
                  renderSlot(_ctx.$slots, "icon", {}, () => [
                    createVNode(
                      _component_ll_icon,
                      normalizeProps(guardReactiveProps(_ctx.iconProps)),
                      null,
                      16
                      /* FULL_PROPS */
                    )
                  ]),
                  createElementVNode(
                    "span",
                    null,
                    toDisplayString(_ctx.buttonProps?.label ?? "\u65B0\u589E"),
                    1
                    /* TEXT */
                  ),
                  _ctx.showExpandType ? (openBlock(), createBlock(_component_ll_icon, {
                    key: 0,
                    class: normalizeClass(unref(bem).m("icon-right")),
                    "icon-name": !dropdownOpen.value ? "icon-line-arrow-down" : "icon-line-arrow-folding"
                  }, null, 8, ["class", "icon-name"])) : createCommentVNode("v-if", true)
                ],
                2
                /* CLASS */
              )
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["disabled"])
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["open", "disabled", "class"]);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=dropdown-button-simple.vue2.mjs.map
