UNPKG

@ark-ui/vue

Version:

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

17 lines (16 loc) 606 B
import { camelize, getCurrentInstance, toHandlerKey } from "vue"; //#region src/utils/use-emits-as-props.ts /** * Attribution: Radix Vue Team * Retrieved from: https://www.radix-vue.com/utilities/use-emit-as-props.html */ function useEmitAsProps(emit) { const vm = getCurrentInstance(); const events = vm?.type.emits; const result = {}; if (!events?.length) console.warn(`No emitted event found. Please check component: ${vm?.type.__name}`); for (const event of events) result[toHandlerKey(camelize(event))] = (...arg) => emit(event, ...arg); return result; } //#endregion export { useEmitAsProps };