import { defineComponent, openBlock, createElementBlock, createVNode, unref, mergeProps, withCtx, createElementVNode, renderSlot, normalizeClass, normalizeStyle, Fragment, renderList, createBlock, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
import { useRouter } from 'vue-router';
import { ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus';
import { MeSvgIcon } from '../../svg-icon/index.mjs';

"use strict";
const _hoisted_1 = { class: "me-more-dropdown" };
const _hoisted_2 = { style: { "cursor": "pointer", "height": "fit-content" } };
const __default__ = defineComponent({
  name: "me-more-dropdown"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    data: { type: Array, required: true, default: () => [] },
    menuIcon: { type: String, required: false, default: "ri-more-2-line" },
    placement: { type: String, required: false, default: "bottom-end" },
    disableTransitions: { type: Boolean, required: false, default: false },
    buttonStyle: { type: String, required: false },
    style: { type: String, required: false },
    activeLabel: { type: String, required: false }
  },
  setup(__props) {
    const props = __props;
    const router = useRouter();
    const onClick = (e, item) => {
      const { toPath, onClick: onClick2 } = item;
      if (onClick2) onClick2(e);
      if (toPath && router) router.push(toPath);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(ElDropdown), mergeProps({
          "hide-on-click": true,
          placement: __props.placement,
          trigger: "click"
        }, _ctx.$attrs, { style: __props.style }), {
          dropdown: withCtx(() => [
            createVNode(unref(ElDropdownMenu), null, {
              default: withCtx(() => [
                (openBlock(true), createElementBlock(
                  Fragment,
                  null,
                  renderList(__props.data, (item, index) => {
                    return openBlock(), createElementBlock(
                      Fragment,
                      { key: index },
                      [
                        !item.hidden ? (openBlock(), createBlock(unref(ElDropdownItem), {
                          key: 0,
                          divided: item.divided,
                          disabled: item.disabled,
                          onClick: ($event) => onClick($event, item),
                          style: normalizeStyle({ color: item.label === __props.activeLabel ? "var(--el-color-primary)" : "" })
                        }, {
                          default: withCtx(() => [
                            createTextVNode(
                              toDisplayString(item.label),
                              1
                              /* TEXT */
                            )
                          ]),
                          _: 2
                          /* DYNAMIC */
                        }, 1032, ["divided", "disabled", "onClick", "style"])) : createCommentVNode("v-if", true)
                      ],
                      64
                      /* STABLE_FRAGMENT */
                    );
                  }),
                  128
                  /* KEYED_FRAGMENT */
                ))
              ]),
              _: 1
              /* STABLE */
            })
          ]),
          default: withCtx(() => [
            createElementVNode("div", _hoisted_2, [
              renderSlot(_ctx.$slots, "default", {}, () => [
                createElementVNode(
                  "div",
                  {
                    style: normalizeStyle(__props.buttonStyle),
                    class: normalizeClass([{ transition: !__props.disableTransitions }, "button flex-center"])
                  },
                  [
                    createVNode(unref(MeSvgIcon), {
                      class: "icon",
                      name: __props.menuIcon
                    }, null, 8, ["name"])
                  ],
                  6
                  /* CLASS, STYLE */
                )
              ])
            ])
          ]),
          _: 3
          /* FORWARDED */
        }, 16, ["placement", "style"])
      ]);
    };
  }
});

export { script as default };
//# sourceMappingURL=more-dropdown.vue2.mjs.map
