import type { ComponentPublicInstance } from 'vue'; import type { MaybeComputedRef, MaybeRef } from './types'; import { resolveUnref } from './resolveUnref'; export type VueInstance = ComponentPublicInstance; export type MaybeElementRef = MaybeRef; export type MaybeComputedElementRef = MaybeComputedRef; export type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null; export type UnRefElementReturn = T extends VueInstance ? Exclude : T | undefined; /** * Get the dom element of a ref of element or Vue component instance * * @param elRef */ export function unrefElement( elRef: MaybeComputedElementRef, ): UnRefElementReturn { const plain = resolveUnref(elRef); return (plain as VueInstance)?.$el ?? plain; }