{"version":3,"file":"forward-ref.js","sources":["../../../../../../packages/components/tooltip-v2/src/forward-ref.tsx"],"sourcesContent":["import { Fragment, defineComponent, ref } from 'vue'\nimport {\n buildProps,\n composeRefs,\n definePropType,\n ensureOnlyChild,\n} from '@element-plus/utils'\n\nimport type { ExtractPropTypes, VNodeArrayChildren } from 'vue'\n\nexport type RefSetter = (el: HTMLElement | null) => void\n\nexport const forwardRefProps = buildProps({\n setRef: { type: definePropType(Function), required: true },\n onlyChild: Boolean,\n} as const)\n\nexport type ForwardRefProps = ExtractPropTypes\n\n// TODO: consider make this component a reusable component without the only child feature.\nexport default defineComponent({\n props: forwardRefProps,\n setup(props, { slots }) {\n const fragmentRef = ref()\n const setRef = composeRefs(fragmentRef, (el) => {\n // vue fragments is represented as a text element.\n // The first element sibling should be the first element children of fragment.\n // This is how we get the element.\n if (el) {\n props.setRef(\n (el as HTMLElement).nextElementSibling as HTMLElement | null\n )\n } else {\n props.setRef(null)\n }\n })\n return () => {\n const [firstChild] = slots.default?.() || []\n const child = props.onlyChild\n ? ensureOnlyChild(firstChild.children as VNodeArrayChildren)\n : firstChild.children\n // Dunno why the ref for jsx complains about the typing issue which was not\n // in template\n return {child}\n }\n },\n})\n"],"names":["forwardRefProps","buildProps","setRef","type","definePropType","Function","required","onlyChild","Boolean","defineComponent","props","slots","composeRefs","fragmentRef","el","ensureOnlyChild","_createVNode","_Fragment"],"mappings":";;;;;;;;;;AAYaA,MAAAA,eAAe,GAAGC,kBAAU,CAAC;AACxCC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,IAAI,EAAEC,sBAAc,CAAYC,QAAZ,CAAtB;AAA6CC,IAAAA,QAAQ,EAAE,IAAA;GADvB;AAExCC,EAAAA,SAAS,EAAEC,OAAAA;AAF6B,CAAD,EAAlC;AAOP,iBAAAC,mBAAA,CAAA;AACA,EAAA,KAAA,EAAA;AACEC,EAAAA,KAAK,MADwB,EAAA;;GAExB,EAAA;AAAUC,IAAAA,MAAAA,WAAAA,GAA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