interface.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import type * as React from 'react';
  2. export type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
  3. export interface ConfigOptions {
  4. top?: string | number;
  5. duration?: number;
  6. prefixCls?: string;
  7. getContainer?: () => HTMLElement;
  8. transitionName?: string;
  9. maxCount?: number;
  10. rtl?: boolean;
  11. }
  12. export interface ArgsProps {
  13. /**
  14. * @descCN 消息通知的内容,接收组件或者字符串
  15. * @descEN The content of the message notification, receiving component or string
  16. */
  17. content: React.ReactNode;
  18. /**
  19. * @descCN 消息通知持续显示的时间
  20. * @descEN How long the message notification remains displayed
  21. */
  22. duration?: number;
  23. /**
  24. * @descCN 消息通知的类型,可以是 'info'、'success'、'error'、'warning' 或 'loading'
  25. * @descEN The type of message notification, which can be 'info', 'success', 'error', 'warning' or 'loading'
  26. */
  27. type?: NoticeType;
  28. /**
  29. * @descCN 消息通知关闭时进行调用的回调函数
  30. * @descEN The callback function called when the message notification is closed
  31. */
  32. onClose?: () => void;
  33. icon?: React.ReactNode;
  34. key?: string | number;
  35. style?: React.CSSProperties;
  36. className?: string;
  37. /**
  38. * @descCN 消息通知点击时的回调函数
  39. * @descEN Callback function when message notification is clicked
  40. */
  41. onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
  42. }
  43. export type JointContent = React.ReactNode | ArgsProps;
  44. export interface MessageType extends PromiseLike<boolean> {
  45. (): void;
  46. }
  47. export type TypeOpen = (content: JointContent,
  48. /**
  49. * @descCN 消息通知持续显示的时间,也可以直接使用 onClose。
  50. * @descEN You can also use onClose directly to determine how long the message notification continues to be displayed.
  51. */
  52. duration?: number | VoidFunction,
  53. /**
  54. * @descCN 消息通知关闭时进行调用的回调函数
  55. * @descEN The callback function called when the message notification is closed
  56. */
  57. onClose?: VoidFunction) => MessageType;
  58. export interface MessageInstance {
  59. info: TypeOpen;
  60. success: TypeOpen;
  61. error: TypeOpen;
  62. warning: TypeOpen;
  63. loading: TypeOpen;
  64. open(args: ArgsProps): MessageType;
  65. destroy(key?: React.Key): void;
  66. }