index.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import type { CSSProperties } from 'vue';
  2. import type { VueNode } from '../_util/type';
  3. import type { NotificationInstance as VCNotificationInstance } from '../vc-notification/Notification';
  4. import useNotification from './useNotification';
  5. export type NotificationPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
  6. export type IconType = 'success' | 'info' | 'error' | 'warning';
  7. export interface ConfigProps {
  8. top?: string | number;
  9. bottom?: string | number;
  10. duration?: number;
  11. prefixCls?: string;
  12. placement?: NotificationPlacement;
  13. getContainer?: () => HTMLElement;
  14. closeIcon?: VueNode | (() => VueNode);
  15. rtl?: boolean;
  16. maxCount?: number;
  17. }
  18. export interface NotificationArgsProps {
  19. message: VueNode | (() => VueNode);
  20. description?: VueNode | (() => VueNode);
  21. btn?: VueNode | (() => VueNode);
  22. key?: string;
  23. onClose?: () => void;
  24. duration?: number | null;
  25. icon?: VueNode | (() => VueNode);
  26. placement?: NotificationPlacement;
  27. maxCount?: number;
  28. style?: CSSProperties;
  29. prefixCls?: string;
  30. class?: string;
  31. readonly type?: IconType;
  32. onClick?: () => void;
  33. top?: string | number;
  34. bottom?: string | number;
  35. getContainer?: () => HTMLElement;
  36. closeIcon?: VueNode | (() => VueNode);
  37. appContext?: any;
  38. }
  39. export interface NotificationInstance {
  40. success(args: NotificationArgsProps): void;
  41. error(args: NotificationArgsProps): void;
  42. info(args: NotificationArgsProps): void;
  43. warning(args: NotificationArgsProps): void;
  44. open(args: NotificationArgsProps): void;
  45. }
  46. export interface NotificationApi extends NotificationInstance {
  47. warn(args: NotificationArgsProps): void;
  48. close(key: string): void;
  49. config(options: ConfigProps): void;
  50. destroy(): void;
  51. useNotification: typeof useNotification;
  52. }
  53. /** @private test Only function. Not work on production */
  54. export declare const getInstance: (cacheKey: string) => Promise<VCNotificationInstance>;
  55. declare const _default: NotificationApi;
  56. export default _default;