ant-design/components/notification/interface.ts

82 lines
1.9 KiB
TypeScript
Raw Normal View History

import type * as React from 'react';
import type { ClosableType } from '../_util/hooks/useClosable';
2022-10-11 21:33:29 +08:00
interface DivProps extends React.HTMLProps<HTMLDivElement> {
'data-testid'?: string;
}
export const NotificationPlacements = [
'top',
'topLeft',
'topRight',
'bottom',
'bottomLeft',
'bottomRight',
] as const;
export type NotificationPlacement = (typeof NotificationPlacements)[number];
export type IconType = 'success' | 'info' | 'error' | 'warning';
export interface ArgsProps {
message: React.ReactNode;
description?: React.ReactNode;
btn?: React.ReactNode;
key?: React.Key;
onClose?: () => void;
duration?: number | null;
showProgress?: boolean;
pauseOnHover?: boolean;
icon?: React.ReactNode;
placement?: NotificationPlacement;
style?: React.CSSProperties;
className?: string;
readonly type?: IconType;
onClick?: () => void;
closeIcon?: React.ReactNode;
closable?: ClosableType;
2022-10-11 21:33:29 +08:00
props?: DivProps;
role?: 'alert' | 'status';
}
2023-02-23 16:38:06 +08:00
type StaticFn = (args: ArgsProps) => void;
export interface NotificationInstance {
2023-02-23 16:38:06 +08:00
success: StaticFn;
error: StaticFn;
info: StaticFn;
warning: StaticFn;
open: StaticFn;
destroy(key?: React.Key): void;
}
export interface GlobalConfigProps {
top?: number;
bottom?: number;
duration?: number;
showProgress?: boolean;
pauseOnHover?: boolean;
prefixCls?: string;
getContainer?: () => HTMLElement | ShadowRoot;
placement?: NotificationPlacement;
closeIcon?: React.ReactNode;
closable?: ClosableType;
rtl?: boolean;
maxCount?: number;
2022-10-11 21:33:29 +08:00
props?: DivProps;
}
export interface NotificationConfig {
top?: number;
bottom?: number;
prefixCls?: string;
getContainer?: () => HTMLElement | ShadowRoot;
placement?: NotificationPlacement;
maxCount?: number;
rtl?: boolean;
stack?: boolean | { threshold?: number };
duration?: number;
showProgress?: boolean;
pauseOnHover?: boolean;
}