{"version":3,"file":"message.vue.mjs","sources":["../../../../../../packages/components/message/src/message.vue"],"sourcesContent":["<script lang=\"ts\">\n  import type { PropType } from 'vue'\n  import { defineComponent, computed, ref, onMounted, onUnmounted } from 'vue'\n  import { getComponentNamespace, getNamespace } from '../../../utils/global-config'\n  import usePopupManager from '../../../hooks/use-popup-manager'\n  import type { IMessageType, IMessage } from './types'\n\n  export default defineComponent({\n    name: getComponentNamespace('Message'),\n    props: {\n      id: {\n        type: String,\n        default: ''\n      },\n      message: {\n        type: [String, Number, Object] as PropType<IMessage>,\n        default: ''\n      },\n      type: {\n        type: String as PropType<IMessageType>,\n        default: 'success'\n      },\n      duration: {\n        type: Number,\n        default: 1500\n      },\n      center: {\n        type: Boolean,\n        default: false\n      },\n      onClose: {\n        type: Function as PropType<() => void>,\n        default: () => {}\n      },\n      offset: {\n        type: Number,\n        default: 20\n      },\n      zIndex: {\n        type: Number,\n        default: 0\n      },\n      showClose: {\n        type: Boolean,\n        default: false\n      },\n      useHTML: Boolean,\n      popupClass: {\n        type: String,\n        default: undefined\n      }\n    },\n    emits: ['destroy'],\n    setup(props) {\n      const ns = getNamespace('message')\n      const cls = computed(() => {\n        return [\n          ns,\n          `${ns}--${props.type}`,\n          props.center && 'is-center',\n          props.showClose && !props.center && `${ns}__show-close`,\n          props.popupClass && props.popupClass\n        ]\n      })\n      const visible = ref(false)\n\n      let timer: any = null\n      const startTimer = () => {\n        timer = setTimeout(() => {\n          visible.value = false\n        }, props.duration)\n      }\n\n      onMounted(() => {\n        visible.value = true\n        if (props.duration !== 0) {\n          startTimer()\n        }\n      })\n\n      onUnmounted(() => {\n        clearTimeout(timer)\n      })\n\n      const { zIndex } = usePopupManager('message', { runOnMounted: true })\n\n      const styles = computed(() => {\n        return {\n          top: `${props.offset}px`,\n          zIndex: zIndex.value\n        }\n      })\n\n      const handleClose = () => {\n        visible.value = false\n      }\n\n      return {\n        ns,\n        cls,\n        styles,\n        visible,\n        handleClose\n      }\n    }\n  })\n</script>\n\n<template>\n  <transition name=\"bn-message-slide-top\" @before-leave=\"onClose\" @after-leave=\"$emit('destroy')\">\n    <div v-show=\"visible\" :class=\"cls\" :style=\"styles\">\n      <slot>\n        <span v-if=\"useHTML\" v-html=\"message\"></span>\n        <span v-else>{{ message }}</span>\n        <span v-if=\"showClose\" :class=\"[`${ns}__close-icon`]\" @click=\"handleClose\"></span>\n      </slot>\n    </div>\n  </transition>\n</template>\n"],"names":["_openBlock","_createBlock","_Transition","_withCtx","_withDirectives","_createElementVNode","_normalizeClass","_normalizeStyle","message","_createElementBlock","_toDisplayString","ns"],"mappings":";;;;;;AA6GkB,SAAA,YAAC,IAAsB,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,QAAA,EAAA;AAAE,EAAA,OAAAA,SAAA,EAAqB,EAAAC,WAAA,CAAAC,UAAA,EAAA;AAAA,IAAG,IAAA,EAAA,sBAAA;AAAA,IAAjE,eAQa,IAAA,CAAA,OAAA;AAAA,IAAA,YAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,KAAA,CAAA,SAAA,CAAA,CAAA;AAAA;;IAPiB,OAAA,EAAAC,QAAA,MAAA;AAAA,MAAaC,cAAA,CAAAC,kBAAA;AAAA,QAAQ,KAAA;AAAA,QAAA;AAAA,UAAA,KAAA,EAAAC,cAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAAA,UAC/C,KAAA,EAIOC,cAAA,CAAA,IAAA,CAAA,MAAA,CAAA;AAAA,SAAA;AAAA;kCAHL,SAA6C,EAAA,IAAA,MAAA;AAAA,YAAA,IAAA,CAAA,OAAA,IAAAP,SAAR,EAAA,EAARQ,mBAAO,MAAA,EAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AAAA,cACpC,WAAA,IAAA,CAAA,OAAA;AAAA,wBACqB,UAArB,CAAA,KAAAR,WAAA,EAAAS,kBAAA;AAAA,cAAkF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