useNotification.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { CSSMotionProps } from 'rc-motion';
  2. import * as React from 'react';
  3. import type { NotificationsProps } from '../Notifications';
  4. import type { OpenConfig, Placement, StackConfig } from '../interface';
  5. type OptionalConfig = Partial<OpenConfig>;
  6. export interface NotificationConfig {
  7. prefixCls?: string;
  8. /** Customize container. It will repeat call which means you should return same container element. */
  9. getContainer?: () => HTMLElement | ShadowRoot;
  10. motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
  11. closeIcon?: React.ReactNode;
  12. closable?: boolean | ({
  13. closeIcon?: React.ReactNode;
  14. } & React.AriaAttributes);
  15. maxCount?: number;
  16. duration?: number;
  17. showProgress?: boolean;
  18. pauseOnHover?: boolean;
  19. /** @private. Config for notification holder style. Safe to remove if refactor */
  20. className?: (placement: Placement) => string;
  21. /** @private. Config for notification holder style. Safe to remove if refactor */
  22. style?: (placement: Placement) => React.CSSProperties;
  23. /** @private Trigger when all the notification closed. */
  24. onAllRemoved?: VoidFunction;
  25. stack?: StackConfig;
  26. /** @private Slot for style in Notifications */
  27. renderNotifications?: NotificationsProps['renderNotifications'];
  28. }
  29. export interface NotificationAPI {
  30. open: (config: OptionalConfig) => void;
  31. close: (key: React.Key) => void;
  32. destroy: () => void;
  33. }
  34. export default function useNotification(rootConfig?: NotificationConfig): [NotificationAPI, React.ReactElement];
  35. export {};