@txdfe/at
Version:
一个设计体系组件库
119 lines (99 loc) • 2.67 kB
TypeScript
/// <reference types="react" />
import * as React from 'react';
export declare enum ToastStatus {
Error = 'error',
Success = 'success',
Warning = 'warning',
Info = 'info',
}
export interface IToastConfigHandler {
readonly onClose?: (key: number | string) => void;
readonly onRemove?: (key: number | string) => void;
readonly onPause?: (key: number | string) => void;
readonly onStart?: (key: number | string) => void;
}
export interface IToastConfigStatic {
/**
* ToastItem 的类名前缀
*/
readonly prefix?: string;
/**
* ToastItem 的标题
*/
readonly title?: string | JSX.Element;
/**
* ToastItem 的描述内容
*/
readonly content?: string | JSX.Element;
/**
* ToastItem 的显示持续时间,0 表示一直存在,以毫秒为单位,默认为 5s
*/
readonly duration?: number;
/**
* 设置额外的操作按钮组
*/
readonly handlers?: string | JSX.Element | null;
/**
* 自定义图标, 若设置为 null 则不渲染
*/
readonly icon?: JSX.Element | null;
/**
* 设置是否以 HTML 的模式渲染
*/
readonly isHTML?: boolean;
/**
* 是否出现关闭按钮
*/
readonly closeable?: boolean;
/**
* 是否支持悬浮暂停
*/
readonly pauseable?: boolean;
/**
* ToastItem 额外的样式名
*/
readonly className?: string;
/**
* ToastItem 额外的样式
*/
readonly style?: React.CSSProperties;
/**
* 设置行动点点击的回调
*/
readonly onClickHandlers?: () => void;
}
export interface IToastConfig extends IToastConfigStatic, IToastConfigHandler {
}
export interface DuplicationCheckProps extends IToastConfig {
status: ToastStatus;
}
export interface ToastProps extends IToastConfigStatic {
/**
* 设置关闭时的回调
*/
readonly onClose?: () => void;
/**
* 设置暂停时的回调
*/
readonly onPause?: () => void;
/**
* 设置出现时的回调
*/
readonly onStart?: () => void;
readonly onRemove?: () => void;
readonly status: ToastStatus;
}
export default class Toast {
static error(props: IToastConfig): void;
static success(props: IToastConfig): void;
static warning(props: IToastConfig): void;
static info(props: IToastConfig): void;
static close(key: string | number): void;
static closeAll(): void;
static getDuplicationKey(props: DuplicationCheckProps): string | number | undefined;
static isDuplicated(props: DuplicationCheckProps): boolean;
static destroy(): void;
static setTemplate(template: React.ComponentClass<ToastProps>): void;
private static manager;
private static getManager;
}