mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 06:21:46 +01:00
feat(useToast): proxy emits
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { ref, nextTick } from 'vue'
|
||||
import { useState } from '#imports'
|
||||
import type { ToastProps } from '../types'
|
||||
import type { ToastProps, ToastEmits } from '../types'
|
||||
import type { EmitsToProps } from '../types/utils'
|
||||
|
||||
export interface Toast extends Omit<ToastProps, 'defaultOpen'> {
|
||||
export interface Toast extends Omit<ToastProps, 'defaultOpen'>, EmitsToProps<ToastEmits> {
|
||||
id: string | number
|
||||
onClick?: (toast: Toast) => void
|
||||
}
|
||||
@@ -38,7 +39,7 @@ export function useToast() {
|
||||
id: generateId(),
|
||||
open: true,
|
||||
...toast
|
||||
}
|
||||
} as Toast
|
||||
|
||||
queue.push(body)
|
||||
|
||||
|
||||
@@ -38,3 +38,9 @@ export type StringOrVNode =
|
||||
| string
|
||||
| VNode
|
||||
| (() => VNode)
|
||||
|
||||
export type EmitsToProps<T> = {
|
||||
[K in keyof T as `on${Capitalize<string & K>}`]: T[K] extends [...args: infer Args]
|
||||
? (...args: Args) => void
|
||||
: never
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user