mirror of
https://github.com/element-plus/element-plus.git
synced 2025-03-13 15:57:11 +08:00
fix(notification): improve type definition and define closeAll function (#2705)
fix #2696
This commit is contained in:
parent
52b474525d
commit
89c01de6f1
@ -2,11 +2,21 @@ import type { VNode } from 'vue'
|
||||
|
||||
|
||||
export type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
|
||||
export type NotificationType = 'success' | 'warning' | 'info' | 'error' | ''
|
||||
export type TypedNotificationOptions = Omit<INotificationOptions, 'type'> | string
|
||||
|
||||
export interface INotificationHandle {
|
||||
close: () => void
|
||||
}
|
||||
|
||||
export type INotification = (options?: INotificationOptions) => INotificationHandle
|
||||
export interface INotification {
|
||||
(options?: INotificationOptions) : INotificationHandle
|
||||
success?: (options: TypedNotificationOptions) => INotificationHandle
|
||||
warning?: (options: TypedNotificationOptions) => INotificationHandle
|
||||
error?: (options: TypedNotificationOptions) => INotificationHandle
|
||||
info?: (options: TypedNotificationOptions) => INotificationHandle
|
||||
closeAll: () => void
|
||||
}
|
||||
|
||||
export type INotificationOptions = {
|
||||
customClass?: string
|
||||
@ -21,7 +31,7 @@ export type INotificationOptions = {
|
||||
offset?: number // defaults 0
|
||||
position?: Position // default top-right
|
||||
showClose?: boolean
|
||||
type?: 'success' | 'warning' | 'info' | 'error' | ''
|
||||
type?: NotificationType
|
||||
title?: string
|
||||
}
|
||||
|
||||
|
@ -142,4 +142,6 @@ export function closeAll(): void {
|
||||
}
|
||||
}
|
||||
|
||||
Notification.closeAll = closeAll
|
||||
|
||||
export default Notification
|
||||
|
Loading…
Reference in New Issue
Block a user