UNPKG

@ark-ui/vue

Version:

A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.

20 lines (19 loc) 577 B
//#region src/components/tour/wait-for-event.ts function waitForEvent(target, event, options) { let cleanup; const { predicate, ...listenerOptions } = options ?? {}; return [new Promise((resolve) => { const element = target?.(); if (!element) return; const handler = (e) => { if (!predicate || predicate(element)) { resolve(e); cleanup?.(); } }; element.addEventListener(event, handler, listenerOptions); cleanup = () => element.removeEventListener(event, handler, listenerOptions); }), () => cleanup?.()]; } //#endregion export { waitForEvent };