'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.js');
var dropdownButtonSimple = require('./dropdown-button-simple.js');
var createNamespace = require('../../../utils/create-namespace.js');

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

exports.default = _sfc_main;
//# sourceMappingURL=dropdown-button-simple.vue2.js.map
