ant-design/components/notification/interface.ts
二货爱吃白萝卜 7664f39d8b
feat: notification support duration (#47141)
* feat: notication support duration

* test: update test
2024-01-24 15:25:56 +08:00

72 lines
1.6 KiB
TypeScript

import type * as React from 'react';
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;
icon?: React.ReactNode;
placement?: NotificationPlacement;
style?: React.CSSProperties;
className?: string;
readonly type?: IconType;
onClick?: () => void;
closeIcon?: React.ReactNode;
props?: DivProps;
role?: 'alert' | 'status';
}
type StaticFn = (args: ArgsProps) => void;
export interface NotificationInstance {
success: StaticFn;
error: StaticFn;
info: StaticFn;
warning: StaticFn;
open: StaticFn;
destroy(key?: React.Key): void;
}
export interface GlobalConfigProps {
top?: number;
bottom?: number;
duration?: number;
prefixCls?: string;
getContainer?: () => HTMLElement | ShadowRoot;
placement?: NotificationPlacement;
closeIcon?: React.ReactNode;
rtl?: boolean;
maxCount?: number;
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;
}