<template>
  <view :class="tabbarClass" :style="tabbarStyle">
    <slot></slot>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed, provide, ref, watch, toRef, reactive } from "vue";
import { classNames, stringifyStyle, createBem } from "../utils";
import { tabbarContextSymbol, tabbarProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "tabbar",
  props: tabbarProps,
  emits: ["update:current"],
  setup(__props, { expose: __expose, emit: __emit }) {
    __expose();
    const props = __props;
    const emit = __emit;
    const bem = createBem("tabbar");
    const innerCurrent = ref(props.current);
    watch(
      () => props.current,
      () => {
        if (props.current !== innerCurrent.value) {
          innerCurrent.value = props.current;
        }
      }
    );
    const select = (name) => {
      innerCurrent.value = name;
      emit("update:current", name);
    };
    provide(
      tabbarContextSymbol,
      reactive({
        color: toRef(props, "color"),
        activeColor: toRef(props, "activeColor"),
        current: innerCurrent,
        select
      })
    );
    const tabbarClass = computed(() => {
      return classNames(bem.b(), bem.m("bordered", props.bordered), props.rootClass);
    });
    const tabbarStyle = computed(() => {
      return stringifyStyle(props.rootStyle);
    });
    const __returned__ = { props, emit, bem, innerCurrent, select, tabbarClass, tabbarStyle };
    return __returned__;
  }
});
</script>

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