UNPKG

@ark-ui/vue

Version:

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

17 lines (14 loc) 465 B
import { getCurrentInstance, toHandlerKey, camelize } from 'vue'; 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; } export { useEmitAsProps };