mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-02 13:17:57 +01:00
feat(useToast): proxy emits
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import { ref, nextTick } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import { useState } from '#imports'
|
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
|
id: string | number
|
||||||
onClick?: (toast: Toast) => void
|
onClick?: (toast: Toast) => void
|
||||||
}
|
}
|
||||||
@@ -38,7 +39,7 @@ export function useToast() {
|
|||||||
id: generateId(),
|
id: generateId(),
|
||||||
open: true,
|
open: true,
|
||||||
...toast
|
...toast
|
||||||
}
|
} as Toast
|
||||||
|
|
||||||
queue.push(body)
|
queue.push(body)
|
||||||
|
|
||||||
|
|||||||
@@ -38,3 +38,9 @@ export type StringOrVNode =
|
|||||||
| string
|
| string
|
||||||
| VNode
|
| VNode
|
||||||
| (() => 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