index.d.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import type { CSSProperties } from 'vue';
  2. import type { Key, VueNode } from '../_util/type';
  3. import type { NotificationInstance } from '../vc-notification/Notification';
  4. export declare function getKeyThenIncreaseKey(): number;
  5. export interface ConfigOptions {
  6. top?: string;
  7. duration?: number;
  8. prefixCls?: string;
  9. getContainer?: () => HTMLElement;
  10. transitionName?: string;
  11. maxCount?: number;
  12. rtl?: boolean;
  13. }
  14. export declare type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
  15. export interface ThenableArgument {
  16. (val: any): void;
  17. }
  18. export interface MessageType extends PromiseLike<any> {
  19. (): void;
  20. }
  21. export interface MessageArgsProps {
  22. content: string | (() => VueNode) | VueNode;
  23. duration?: number;
  24. type?: NoticeType;
  25. prefixCls?: string;
  26. rootPrefixCls?: string;
  27. getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
  28. onClose?: () => void;
  29. icon?: (() => VueNode) | VueNode;
  30. key?: string | number;
  31. style?: CSSProperties;
  32. class?: string;
  33. appContext?: any;
  34. onClick?: (e: MouseEvent) => void;
  35. }
  36. declare type ConfigDuration = number;
  37. declare type JointContent = VueNode | MessageArgsProps;
  38. export declare type ConfigOnClose = () => void;
  39. export declare function attachTypeApi(originalApi: MessageApi, type: NoticeType): void;
  40. export interface MessageInstance {
  41. info(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  42. success(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  43. error(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  44. warning(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  45. loading(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  46. open(args: MessageArgsProps): MessageType;
  47. }
  48. export interface MessageApi extends MessageInstance {
  49. warn(content: JointContent, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
  50. config(options: ConfigOptions): void;
  51. destroy(messageKey?: Key): void;
  52. }
  53. /** @private test Only function. Not work on production */
  54. export declare const getInstance: () => NotificationInstance;
  55. declare const _default: MessageApi;
  56. export default _default;