2017-10-17 16:36:12 +08:00
|
|
|
import Vue, { VNode } from 'vue'
|
|
|
|
import { MessageType } from './message'
|
|
|
|
|
2018-01-30 13:20:58 +08:00
|
|
|
export type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
|
|
|
|
|
2017-10-17 16:36:12 +08:00
|
|
|
/** Notification Component */
|
|
|
|
export declare class ElNotificationComponent extends Vue {
|
|
|
|
/** Close the Notification instance */
|
2017-10-26 23:17:18 +08:00
|
|
|
close (): void
|
2017-10-17 16:36:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ElNotificationOptions {
|
|
|
|
/** Title */
|
|
|
|
title: string
|
|
|
|
|
|
|
|
/** Description text */
|
|
|
|
message: string | VNode
|
|
|
|
|
|
|
|
/** Notification type */
|
2017-11-02 19:43:09 +08:00
|
|
|
type?: MessageType
|
2017-10-17 16:36:12 +08:00
|
|
|
|
|
|
|
/** Custom icon's class. It will be overridden by type */
|
2017-11-02 19:43:09 +08:00
|
|
|
iconClass?: string
|
2017-10-17 16:36:12 +08:00
|
|
|
|
|
|
|
/** Custom class name for Notification */
|
2017-11-02 19:43:09 +08:00
|
|
|
customClass?: string
|
2017-10-17 16:36:12 +08:00
|
|
|
|
|
|
|
/** Duration before close. It will not automatically close if set 0 */
|
2017-11-02 19:43:09 +08:00
|
|
|
duration?: number
|
2017-10-17 16:36:12 +08:00
|
|
|
|
2017-10-18 18:31:03 +08:00
|
|
|
/** Whether to show a close button */
|
2017-11-02 19:43:09 +08:00
|
|
|
showClose?: boolean
|
2017-10-18 18:31:03 +08:00
|
|
|
|
|
|
|
/** Whether message is treated as HTML string */
|
|
|
|
dangerouslyUseHTMLString?: boolean
|
|
|
|
|
2017-10-17 16:36:12 +08:00
|
|
|
/** Callback function when closed */
|
2017-11-02 19:43:09 +08:00
|
|
|
onClose?: () => void
|
2017-10-17 16:36:12 +08:00
|
|
|
|
2017-10-18 18:31:03 +08:00
|
|
|
/** Callback function when notification clicked */
|
2017-11-02 19:43:09 +08:00
|
|
|
onClick?: () => void
|
2017-10-18 18:31:03 +08:00
|
|
|
|
2017-10-17 16:36:12 +08:00
|
|
|
/** Offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset */
|
2017-11-02 19:43:09 +08:00
|
|
|
offset?: number
|
2018-01-30 13:20:58 +08:00
|
|
|
|
|
|
|
/** custom position */
|
|
|
|
position?: NotificationPosition
|
2017-10-17 16:36:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ElNotification {
|
|
|
|
/** Show a notification */
|
|
|
|
(options: ElNotificationOptions): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show a success notification */
|
|
|
|
success (message: string | VNode): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show a success notification */
|
|
|
|
success (options: ElNotificationOptions): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show a warning notification */
|
|
|
|
warning (message: string | VNode): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show a warning notification */
|
|
|
|
warning (options: ElNotificationOptions): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show an info notification */
|
|
|
|
info (message: string | VNode): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show an info notification */
|
|
|
|
info (options: ElNotificationOptions): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show an error notification */
|
|
|
|
error (message: string | VNode): ElNotificationComponent
|
|
|
|
|
|
|
|
/** Show an error notification */
|
|
|
|
error (options: ElNotificationOptions): ElNotificationComponent
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module 'vue/types/vue' {
|
|
|
|
interface Vue {
|
|
|
|
/** Displays a global notification message at the upper right corner of the page */
|
|
|
|
$notify: ElNotification
|
|
|
|
}
|
|
|
|
}
|