<template>
  <view
    v-if="realVisible"
    :class="overlayClass"
    :style="overlayStyle"
    @click="onClick"
    @transitionend="onTransitionEnd"
    @touchmove.stop.prevent
  >
    <slot></slot>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed, reactive, toRef } from "vue";
import { classNames, stringifyStyle, createBem } from "../utils";
import { useTransition } from "../use";
import { overlayProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "overlay",
  props: overlayProps,
  emits: ["click"],
  setup(__props, { expose: __expose, emit: __emit }) {
    __expose();
    const props = __props;
    const emit = __emit;
    const bem = createBem("overlay");
    const onClick = (event) => {
      emit("click", event);
    };
    const { realVisible, transitionClass, onTransitionEnd } = useTransition(
      reactive({
        visible: toRef(props, "visible"),
        duration: toRef(props, "duration"),
        prefix: bem.m("")
      })
    );
    const overlayClass = computed(() => {
      return classNames(
        bem.b(),
        bem.m("transparent", props.transparent),
        transitionClass.value,
        props.rootClass
      );
    });
    const overlayStyle = computed(() => {
      return stringifyStyle(
        {
          zIndex: props.zIndex,
          backgroundColor: props.background,
          transitionDuration: props.duration + "ms"
        },
        props.rootStyle
      );
    });
    const __returned__ = { props, emit, bem, onClick, realVisible, transitionClass, onTransitionEnd, overlayClass, overlayStyle };
    return __returned__;
  }
});
</script>

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