<template>
  <view :class="menuClass" :style="menuStyle">
    <sar-menu-item
      v-for="(option, i) in options"
      :key="i"
      :text="option.text"
      :icon="option.icon"
      :icon-family="option.iconFamily"
      :disabled="option.disabled"
      :with-icon="withIcon"
      :direction="direction"
      @click="onClick(option)"
    />
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed } from "vue";
import { classNames, stringifyStyle, createBem } from "../utils";
import SarMenuItem from "../menu-item/menu-item.vue";
import { menuProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "menu",
  props: menuProps,
  emits: ["select"],
  setup(__props, { expose: __expose, emit: __emit }) {
    __expose();
    const props = __props;
    const emit = __emit;
    const bem = createBem("menu");
    const onClick = (option) => {
      if (!option.disabled) {
        emit("select", option);
      }
    };
    const withIcon = computed(() => {
      return props.options.some((option) => !!option.icon);
    });
    const menuClass = computed(() => {
      return classNames(
        bem.b(),
        bem.m(props.direction),
        bem.m(props.theme),
        bem.m("with-icon", withIcon.value),
        props.rootClass
      );
    });
    const menuStyle = computed(() => {
      return stringifyStyle(props.rootStyle);
    });
    const __returned__ = { props, emit, bem, onClick, withIcon, menuClass, menuStyle, SarMenuItem };
    return __returned__;
  }
});
</script>

<style lang="scss">
@use './index.scss';
</style>