2019-01-01 12:13:51 +08:00
|
|
|
// Project: https://github.com/vueComponent/ant-design-vue
|
|
|
|
// Definitions by: akki-jat <https://github.com/akki-jat>
|
|
|
|
// Definitions: https://github.com/vueComponent/ant-design-vue/types
|
|
|
|
|
|
|
|
import { AntdComponent } from './component';
|
2020-08-18 22:05:01 +08:00
|
|
|
import { VNodeChild, CSSProperties } from 'vue';
|
|
|
|
export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
|
|
export interface NotificationOptions extends NotificationConfigOptions {
|
2019-01-01 12:13:51 +08:00
|
|
|
/**
|
|
|
|
* Customized close button
|
|
|
|
* @type VNode | Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
btn?: VNodeChild | JSX.Element | Function;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Customized CSS class
|
|
|
|
* @type string
|
|
|
|
*/
|
|
|
|
class?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The content of notification box (required)
|
|
|
|
* @type string | VNode | Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
description: VNodeChild | JSX.Element | Function;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Customized icon
|
|
|
|
* @type VNode | Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
icon?: VNodeChild | JSX.Element | Function;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The unique identifier of the Notification
|
|
|
|
* @type string
|
|
|
|
*/
|
|
|
|
key?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The title of notification box (required)
|
|
|
|
* @type string | VNode | Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
message: VNodeChild | JSX.Element | Function;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Customized inline style
|
|
|
|
* @type object | string
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
style?: CSSProperties | string;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify a function that will be called when the close button is clicked
|
|
|
|
* @type Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
onClose?: () => void;
|
2019-01-05 11:24:56 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify a function that will be called when the notification is clicked
|
|
|
|
* @type Function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
onClick?: () => void;
|
2019-01-01 12:13:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface NotificationConfigOptions {
|
|
|
|
/**
|
|
|
|
* Distance from the bottom of the viewport, when placement is bottomRight or bottomLeft (unit: pixels).
|
|
|
|
* @default '24px'
|
|
|
|
* @type string
|
|
|
|
*/
|
|
|
|
bottom?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Time in seconds before Notification is closed. When set to 0 or null, it will never be closed automatically
|
|
|
|
* @default 4.5
|
|
|
|
* @type number
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
duration?: number | null;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the mount node for Notification
|
|
|
|
* @default () => document.body
|
|
|
|
* @type Function
|
|
|
|
*/
|
|
|
|
getContainer?: () => HTMLElement;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Position of Notification, can be one of topLeft topRight bottomLeft bottomRight
|
|
|
|
* @default 'topRight'
|
|
|
|
* @type string
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
placement?: NotificationPlacement;
|
2019-01-01 12:13:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Distance from the top of the viewport, when placement is topRight or topLeft (unit: pixels).
|
|
|
|
* @default '24px'
|
|
|
|
* @type string
|
|
|
|
*/
|
|
|
|
top?: string;
|
2020-08-18 22:05:01 +08:00
|
|
|
/**
|
2020-08-19 11:40:33 +08:00
|
|
|
* custom close icon
|
|
|
|
* @type VNode | function
|
|
|
|
*/
|
2020-08-18 22:05:01 +08:00
|
|
|
closeIcon?: VNodeChild | JSX.Element | Function;
|
2019-01-01 12:13:51 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 11:40:33 +08:00
|
|
|
export interface Notification {
|
2019-01-01 12:13:51 +08:00
|
|
|
success(config: NotificationOptions): void;
|
|
|
|
warning(config: NotificationOptions): void;
|
|
|
|
warn(config: NotificationOptions): void;
|
|
|
|
info(config: NotificationOptions): void;
|
|
|
|
error(config: NotificationOptions): void;
|
|
|
|
open(config: NotificationOptions): void;
|
|
|
|
config(options: NotificationConfigOptions): void;
|
|
|
|
close(key: string): void;
|
|
|
|
destroy(): void;
|
|
|
|
}
|