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