{"version":3,"file":"popup.vue.mjs","sources":["../../../../../../packages/components/popup/src/popup.vue"],"sourcesContent":["<script lang=\"ts\">\n  import { computed, defineComponent, ref } from 'vue'\n  import type { PropType, StyleValue } from 'vue'\n  import { getComponentNamespace, getNamespace } from '../../../utils/global-config'\n  import Trigger from '../../trigger'\n  import { addUnit } from '../../../shared/utils'\n  import type { TriggerPosition } from '../../trigger/src/_trigger'\n  import { isUndefined } from '../../../utils/is'\n\n  export default defineComponent({\n    name: getComponentNamespace('Popup'),\n    components: {\n      Trigger\n    },\n    props: {\n      trigger: {\n        type: String as PropType<'click' | 'hover'>,\n        default: 'click'\n      },\n      minWidth: {\n        type: [String, Number],\n        default: 150\n      },\n      width: {\n        type: [String, Number],\n        default: 'auto'\n      },\n      placement: {\n        type: String as PropType<TriggerPosition>,\n        default: 'bottom'\n      },\n      showArrow: {\n        type: Boolean,\n        default: false\n      },\n      contentClass: {\n        type: String,\n        default: undefined\n      },\n      offset: {\n        type: Number,\n        default: undefined\n      },\n      disabled: {\n        type: Boolean,\n        default: false\n      }\n    },\n    emits: ['show', 'hide'],\n    setup(props, { expose }) {\n      const ns = getNamespace('popup')\n      const popupVisible = ref(false)\n\n      const contentCls = computed(() => [`${ns}__content`, props.contentClass])\n\n      const contentStyle = computed(() => {\n        const style: StyleValue = {}\n        style.minWidth = addUnit(props.minWidth)\n        style.width = addUnit(props.width)\n        return style\n      })\n\n      const arrowStyle = computed(() => {\n        const style: Record<string, string> = {\n          '--bn-trigger-arrow-background-color': '#fff'\n        }\n\n        return style\n      })\n\n      const computedOffset = computed(() => {\n        if (isUndefined(props.offset) && props.showArrow) return 12\n        if (isUndefined(props.offset)) return 6\n        return props.offset\n      })\n\n      const changePopupVisible = (visible: boolean) => {\n        popupVisible.value = visible\n      }\n\n      expose({\n        changePopupVisible\n      })\n\n      return {\n        ns,\n        contentCls,\n        contentStyle,\n        popupVisible,\n        arrowStyle,\n        computedOffset\n      }\n    }\n  })\n</script>\n\n<template>\n  <Trigger\n    v-model:popup-visible=\"popupVisible\"\n    :trigger=\"trigger\"\n    :position=\"placement\"\n    :show-arrow=\"showArrow\"\n    :popup-offset=\"computedOffset\"\n    :arrow-style=\"arrowStyle\"\n    :disabled=\"disabled\"\n    @show=\"$emit('show')\"\n    @hide=\"$emit('hide')\"\n  >\n    <template #default>\n      <slot name=\"trigger\" :show=\"popupVisible\"></slot>\n    </template>\n    <template #content>\n      <div :class=\"contentCls\" :style=\"contentStyle\">\n        <slot name=\"content\"></slot>\n      </div>\n    </template>\n  </Trigger>\n</template>\n"],"names":["_resolveComponent","trigger","showArrow","arrowStyle","disabled","_renderSlot","_withCtx","_createElementVNode","contentStyle","_normalizeStyle"],"mappings":";;;;;6BAiGEA,iBAmBU,SAAA,CAAA,CAAA;;IAjBP,iBAASC,IAAO,CAAA,YAAA;AAAA,IAChB,uBAAA,EAAmB,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,YAAA,GAAA,MAAA,CAAA;AAAA,IACnB,SAAYC,IAAAA,CAAAA,OAAAA;AAAAA,IACZ,UAAY,IAAA,CAAA,SAAA;AAAA,IACZ,cAAW,IAAEC,CAAAA,SAAAA;AAAAA,IACb,gBAAUC,IAAAA,CAAAA,cAAAA;AAAAA,IACV,eAAI,IAAA,CAAA,UAAA;AAAA,IACJ,UAAI,IAAA,CAAA,QAAA;AAAA,IAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,KAAA,CAAA,MAAA,CAAA,CAAA;AAAA,IAEM,MAAA,EAAO,MACiC,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,KAAA,CAAA,MAAA,CAAA,CAAA;AAAA,GAAA,EAAA;AAAA;MAExCC,UAAA,CAAO,KAGV,MAAA,EAAA,SAAA,EAAA,EAAA,IAAA,EAAA,IAAA,CAAA,cAAA,CAAA;AAAA,KAAA,CAAA;AAAA,IAFK,OAAA,EAAAC,QAAA,MAAA;AAAA,MAAAC,kBAAA;AAAA,QAAoB,KAAA;AAAA,QAAEC;AAAAA,UAAAA,KAAAA,EAAAA,cAAAA,CAAAA,IAAAA,CAAAA,UAAAA,CAAAA;AAAAA,UAC/B,KAAA,EAA4BC,cAAA,CAAA,IAAA,CAAA,YAAA,CAAA;AAAA,SAAA;AAAA;;;;;;;;;;;;;;;"}