UNPKG

jadq-x-vue

Version:

Craft AI-driven interfaces effortlessly

26 lines (25 loc) 600 B
import { ref as s, getCurrentInstance as a, onMounted as i, onBeforeUnmount as m } from "vue"; function d(o) { const e = s(null); let t = null; const n = a(), f = () => { var u, l; if (!n) return; const r = n.refs[o]; if (r) { e.value = r; return; } const c = (l = (u = n.proxy) == null ? void 0 : u.$el) == null ? void 0 : l.querySelector(`[ref="${o}"]`); e.value = c ?? null; }; return i(() => { t = window.setTimeout(f, 0); }), m(() => { t && clearTimeout(t), e.value = null; }), e; } export { d as default, d as useTemplateRef };