UNPKG

2.34 kBTypeScriptView Raw
1import Vue, { VNode } from 'vue'
2import { MessageType } from './message'
3
4export type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
5
6/** Notification Component */
7export declare class ElNotificationComponent extends Vue {
8 /** Close the Notification instance */
9 close (): void
10}
11
12export interface ElNotificationOptions {
13 /** Title */
14 title: string
15
16 /** Description text */
17 message: string | VNode
18
19 /** Notification type */
20 type?: MessageType
21
22 /** Custom icon's class. It will be overridden by type */
23 iconClass?: string
24
25 /** Custom class name for Notification */
26 customClass?: string
27
28 /** Duration before close. It will not automatically close if set 0 */
29 duration?: number
30
31 /** Whether to show a close button */
32 showClose?: boolean
33
34 /** Whether message is treated as HTML string */
35 dangerouslyUseHTMLString?: boolean
36
37 /** Callback function when closed */
38 onClose?: () => void
39
40 /** Callback function when notification clicked */
41 onClick?: () => void
42
43 /** Offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset */
44 offset?: number
45
46 /** custom position */
47 position?: NotificationPosition
48}
49
50export interface ElNotification {
51 /** Show a notification */
52 (options: ElNotificationOptions): ElNotificationComponent
53
54 /** Show a success notification */
55 success (message: string | VNode): ElNotificationComponent
56
57 /** Show a success notification */
58 success (options: ElNotificationOptions): ElNotificationComponent
59
60 /** Show a warning notification */
61 warning (message: string | VNode): ElNotificationComponent
62
63 /** Show a warning notification */
64 warning (options: ElNotificationOptions): ElNotificationComponent
65
66 /** Show an info notification */
67 info (message: string | VNode): ElNotificationComponent
68
69 /** Show an info notification */
70 info (options: ElNotificationOptions): ElNotificationComponent
71
72 /** Show an error notification */
73 error (message: string | VNode): ElNotificationComponent
74
75 /** Show an error notification */
76 error (options: ElNotificationOptions): ElNotificationComponent
77}
78
79declare module 'vue/types/vue' {
80 interface Vue {
81 /** Displays a global notification message at the upper right corner of the page */
82 $notify: ElNotification
83 }
84}