chore: update type notification (#2710)

* chore: update type Notification
pull/2716/head
binhaoCen 2020-08-18 22:05:01 +08:00 committed by GitHub
parent b2d7ace9ff
commit 0c15958484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 40 deletions

View File

@ -3,14 +3,14 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types // Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from './component'; import { AntdComponent } from './component';
import { VNode } from 'vue'; import { VNodeChild, CSSProperties } from 'vue';
export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
export interface NotificationOptions { export interface NotificationOptions extends NotificationConfigOptions {
/** /**
* Customized close button * Customized close button
* @type VNode | Function * @type VNode | Function
*/ */
btn?: VNode | Function; btn?: VNodeChild | JSX.Element | Function;
/** /**
* Customized CSS class * Customized CSS class
@ -22,20 +22,13 @@ export interface NotificationOptions {
* The content of notification box (required) * The content of notification box (required)
* @type string | VNode | Function * @type string | VNode | Function
*/ */
description: string | VNode | Function; description: VNodeChild | JSX.Element | Function;
/**
* Time in seconds before Notification is closed. When set to 0 or null, it will never be closed automatically
* @default 4.5
* @type number
*/
duration?: number;
/** /**
* Customized icon * Customized icon
* @type VNode | Function * @type VNode | Function
*/ */
icon?: VNode | Function; icon?: VNodeChild | JSX.Element | Function;
/** /**
* The unique identifier of the Notification * The unique identifier of the Notification
@ -47,38 +40,25 @@ export interface NotificationOptions {
* The title of notification box (required) * The title of notification box (required)
* @type string | VNode | Function * @type string | VNode | Function
*/ */
message: string | VNode | Function; message: VNodeChild | JSX.Element | Function;
/**
* Position of Notification, can be one of topLeft topRight bottomLeft bottomRight
* @default 'topRight'
* @type string
*/
placement?: string;
/** /**
* Customized inline style * Customized inline style
* @type object | string * @type object | string
*/ */
style?: object | string; style?: CSSProperties | string;
/** /**
* Specify a function that will be called when the close button is clicked * Specify a function that will be called when the close button is clicked
* @type Function * @type Function
*/ */
onClose?: Function; onClose?: () => void;
/** /**
* Specify a function that will be called when the notification is clicked * Specify a function that will be called when the notification is clicked
* @type Function * @type Function
*/ */
onClick?: Function; onClick?: () => void;
closeIcon?: any;
getContainer?: () => HTMLElement;
bottom?: string;
top?: string;
} }
export interface NotificationConfigOptions { export interface NotificationConfigOptions {
@ -94,7 +74,7 @@ export interface NotificationConfigOptions {
* @default 4.5 * @default 4.5
* @type number * @type number
*/ */
duration?: number; duration?: number | null;
/** /**
* Return the mount node for Notification * Return the mount node for Notification
@ -108,7 +88,7 @@ export interface NotificationConfigOptions {
* @default 'topRight' * @default 'topRight'
* @type string * @type string
*/ */
placement?: string; placement?: NotificationPlacement;
/** /**
* Distance from the top of the viewport, when placement is topRight or topLeft (unit: pixels). * Distance from the top of the viewport, when placement is topRight or topLeft (unit: pixels).
@ -116,11 +96,14 @@ export interface NotificationConfigOptions {
* @type string * @type string
*/ */
top?: string; top?: string;
/**
closeIcon?: any; * custom close icon
* @type VNode | function
*/
closeIcon?: VNodeChild | JSX.Element | Function;
} }
export declare class Notification { export interface NotificationApi {
success(config: NotificationOptions): void; success(config: NotificationOptions): void;
warning(config: NotificationOptions): void; warning(config: NotificationOptions): void;
warn(config: NotificationOptions): void; warn(config: NotificationOptions): void;
@ -132,8 +115,3 @@ export declare class Notification {
destroy(): void; destroy(): void;
} }
declare module 'vue/types/vue' {
interface Vue {
$notification: Notification;
}
}