mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 06:21:46 +01:00
feat(Form): new component (#439)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
18
src/runtime/composables/useFormEvents.ts
Normal file
18
src/runtime/composables/useFormEvents.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { inject } from 'vue'
|
||||
import { UseEventBusReturn } from '@vueuse/core'
|
||||
import { FormEvent } from '../types'
|
||||
|
||||
export const useFormEvents = () => {
|
||||
const formBus = inject<UseEventBusReturn<FormEvent, string> | undefined>('form-events', undefined)
|
||||
const formPath = inject<string | undefined>('form-path', undefined)
|
||||
|
||||
const emitFormBlur = () => {
|
||||
if (formBus && formPath) {
|
||||
formBus.emit({ type: 'blur', path: formPath })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
emitFormBlur
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user