You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
9.9 KiB
1 lines
9.9 KiB
{"ast":null,"code":"import { defineComponent, inject, ref, computed, unref, watch, onMounted, provide, openBlock, createElementBlock, normalizeStyle, normalizeClass, renderSlot, createVNode, withCtx, Fragment, createTextVNode, toDisplayString, createCommentVNode } from 'vue';\nimport { offset } from '@floating-ui/dom';\nimport ElVisuallyHidden from '../../visual-hidden/src/visual-hidden2.mjs';\nimport { tooltipV2RootKey, tooltipV2ContentKey } from './constants.mjs';\nimport { tooltipV2ContentProps } from './content.mjs';\nimport { tooltipV2CommonProps } from './common.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useFloating, arrowMiddleware } from '../../../hooks/use-floating/index.mjs';\nimport { useZIndex } from '../../../hooks/use-z-index/index.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nconst __default__ = defineComponent({\n name: \"ElTooltipV2Content\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: {\n ...tooltipV2ContentProps,\n ...tooltipV2CommonProps\n },\n setup(__props) {\n const props = __props;\n const {\n triggerRef,\n contentId\n } = inject(tooltipV2RootKey);\n const placement = ref(props.placement);\n const strategy = ref(props.strategy);\n const arrowRef = ref(null);\n const {\n referenceRef,\n contentRef,\n middlewareData,\n x,\n y,\n update\n } = useFloating({\n placement,\n strategy,\n middleware: computed(() => {\n const middleware = [offset(props.offset)];\n if (props.showArrow) {\n middleware.push(arrowMiddleware({\n arrowRef\n }));\n }\n return middleware;\n })\n });\n const zIndex = useZIndex().nextZIndex();\n const ns = useNamespace(\"tooltip-v2\");\n const side = computed(() => {\n return placement.value.split(\"-\")[0];\n });\n const contentStyle = computed(() => {\n return {\n position: unref(strategy),\n top: `${unref(y) || 0}px`,\n left: `${unref(x) || 0}px`,\n zIndex\n };\n });\n const arrowStyle = computed(() => {\n if (!props.showArrow) return {};\n const {\n arrow\n } = unref(middlewareData);\n return {\n [`--${ns.namespace.value}-tooltip-v2-arrow-x`]: `${arrow == null ? void 0 : arrow.x}px` || \"\",\n [`--${ns.namespace.value}-tooltip-v2-arrow-y`]: `${arrow == null ? void 0 : arrow.y}px` || \"\"\n };\n });\n const contentClass = computed(() => [ns.e(\"content\"), ns.is(\"dark\", props.effect === \"dark\"), ns.is(unref(strategy)), props.contentClass]);\n watch(arrowRef, () => update());\n watch(() => props.placement, val => placement.value = val);\n onMounted(() => {\n watch(() => props.reference || triggerRef.value, el => {\n referenceRef.value = el || void 0;\n }, {\n immediate: true\n });\n });\n provide(tooltipV2ContentKey, {\n arrowRef\n });\n return (_ctx, _cache) => {\n return openBlock(), createElementBlock(\"div\", {\n ref_key: \"contentRef\",\n ref: contentRef,\n style: normalizeStyle(unref(contentStyle)),\n \"data-tooltip-v2-root\": \"\"\n }, [!_ctx.nowrap ? (openBlock(), createElementBlock(\"div\", {\n key: 0,\n \"data-side\": unref(side),\n class: normalizeClass(unref(contentClass))\n }, [renderSlot(_ctx.$slots, \"default\", {\n contentStyle: unref(contentStyle),\n contentClass: unref(contentClass)\n }), createVNode(unref(ElVisuallyHidden), {\n id: unref(contentId),\n role: \"tooltip\"\n }, {\n default: withCtx(() => [_ctx.ariaLabel ? (openBlock(), createElementBlock(Fragment, {\n key: 0\n }, [createTextVNode(toDisplayString(_ctx.ariaLabel), 1)], 64)) : renderSlot(_ctx.$slots, \"default\", {\n key: 1\n })]),\n _: 3\n }, 8, [\"id\"]), renderSlot(_ctx.$slots, \"arrow\", {\n style: normalizeStyle(unref(arrowStyle)),\n side: unref(side)\n })], 10, [\"data-side\"])) : createCommentVNode(\"v-if\", true)], 4);\n };\n }\n});\nvar TooltipV2Content = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"content.vue\"]]);\nexport { TooltipV2Content as default };","map":{"version":3,"names":["name","triggerRef","contentId","inject","tooltipV2RootKey","placement","ref","props","strategy","arrowRef","referenceRef","contentRef","middlewareData","x","y","update","useFloating","middleware","computed","offset","showArrow","push","arrowMiddleware","zIndex","useZIndex","nextZIndex","ns","useNamespace","side","value","split","contentStyle","position","unref","top","left","arrowStyle","arrow","namespace","contentClass","e","is","effect","watch","val","onMounted","reference","el","immediate","provide","tooltipV2ContentKey","_ctx","_cache","openBlock","createElementBlock","ref_key","style","normalizeStyle","nowrap"],"sources":["../../../../../../packages/components/tooltip-v2/src/content.vue"],"sourcesContent":["<template>\n <div ref=\"contentRef\" :style=\"contentStyle\" data-tooltip-v2-root>\n <div v-if=\"!nowrap\" :data-side=\"side\" :class=\"contentClass\">\n <slot :content-style=\"contentStyle\" :content-class=\"contentClass\" />\n <el-visually-hidden :id=\"contentId\" role=\"tooltip\">\n <template v-if=\"ariaLabel\">\n {{ ariaLabel }}\n </template>\n <slot v-else />\n </el-visually-hidden>\n <slot name=\"arrow\" :style=\"arrowStyle\" :side=\"side\" />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, inject, onMounted, provide, ref, unref, watch } from 'vue'\nimport { offset } from '@floating-ui/dom'\nimport {\n arrowMiddleware,\n useFloating,\n useNamespace,\n useZIndex,\n} from '@element-plus/hooks'\nimport ElVisuallyHidden from '@element-plus/components/visual-hidden'\nimport { tooltipV2ContentKey, tooltipV2RootKey } from './constants'\nimport { tooltipV2ContentProps } from './content'\nimport { tooltipV2CommonProps } from './common'\n\nimport type { CSSProperties } from 'vue'\nimport type { Middleware } from '@floating-ui/dom'\n\ndefineOptions({\n name: 'ElTooltipV2Content',\n})\n\nconst props = defineProps({ ...tooltipV2ContentProps, ...tooltipV2CommonProps })\n\nconst { triggerRef, contentId } = inject(tooltipV2RootKey)!\n\nconst placement = ref(props.placement)\nconst strategy = ref(props.strategy)\nconst arrowRef = ref<HTMLElement | null>(null)\n\nconst { referenceRef, contentRef, middlewareData, x, y, update } = useFloating({\n placement,\n strategy,\n middleware: computed(() => {\n const middleware: Middleware[] = [offset(props.offset)]\n\n if (props.showArrow) {\n middleware.push(\n arrowMiddleware({\n arrowRef,\n })\n )\n }\n\n return middleware\n }),\n})\n\nconst zIndex = useZIndex().nextZIndex()\n\nconst ns = useNamespace('tooltip-v2')\n\nconst side = computed(() => {\n return placement.value.split('-')[0]\n})\n\nconst contentStyle = computed<CSSProperties>(() => {\n return {\n position: unref(strategy),\n top: `${unref(y) || 0}px`,\n left: `${unref(x) || 0}px`,\n zIndex,\n }\n})\n\nconst arrowStyle = computed<CSSProperties>(() => {\n if (!props.showArrow) return {}\n\n const { arrow } = unref(middlewareData)\n\n return {\n [`--${ns.namespace.value}-tooltip-v2-arrow-x`]: `${arrow?.x}px` || '',\n [`--${ns.namespace.value}-tooltip-v2-arrow-y`]: `${arrow?.y}px` || '',\n }\n})\n\nconst contentClass = computed(() => [\n ns.e('content'),\n ns.is('dark', props.effect === 'dark'),\n ns.is(unref(strategy)),\n props.contentClass,\n])\n\nwatch(arrowRef, () => update())\n\nwatch(\n () => props.placement,\n (val) => (placement.value = val)\n)\n\nonMounted(() => {\n watch(\n () => props.reference || triggerRef.value,\n (el) => {\n referenceRef.value = el || undefined\n },\n {\n immediate: true,\n }\n )\n})\n\nprovide(tooltipV2ContentKey, { arrowRef })\n</script>\n"],"mappings":";;;;;;;;;;mCAgCc;EACZA,IAAM;AACR;;;;;;;;;IAIA,MAAM;MAAEC,UAAA;MAAYC;IAAU,IAAIC,MAAA,CAAOC,gBAAgB;IAEnD,MAAAC,SAAA,GAAYC,GAAI,CAAAC,KAAA,CAAMF,SAAS;IAC/B,MAAAG,QAAA,GAAWF,GAAI,CAAAC,KAAA,CAAMC,QAAQ;IAC7B,MAAAC,QAAA,GAAWH,GAAA,CAAwB,IAAI;IAEvC;MAAEI,YAAA;MAAcC,UAAY;MAAAC,cAAA;MAAgBC,CAAA;MAAGC,CAAG;MAAAC;IAAA,IAAWC,WAAY;MAC7EX,SAAA;MACAG,QAAA;MACAS,UAAA,EAAYC,QAAA,CAAS,MAAM;QACzB,MAAMD,UAA2B,IAACE,MAAO,CA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