jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
50 lines (49 loc) • 2.04 kB
TypeScript
/**
* toast提示组件, 单例模式,App级别只需要一个ToastComponent,引入了多个会兼容,也只有第一个生效
*/
import React from 'react';
import type { ToastComponentProps, ToastItem, ToastMessageProps } from './types';
interface ToastComponentState {
items: Array<ToastItem>;
}
export declare class ToastComponent extends React.Component<ToastComponentProps, ToastComponentState> {
static defaultProps: Pick<ToastComponentProps, 'position' | 'closeButton' | 'timeout' | 'errorTimeout' | 'items'>;
static themeKey: string;
hasRendered: boolean;
state: ToastComponentState;
componentDidMount(): void;
componentWillUnmount(): void;
notifiy(level: ToastItem['level'], content: string, config?: Partial<ToastItem>): void;
success(content: string, config?: Partial<ToastItem>): void;
error(content: string, config?: Partial<ToastItem>): void;
info(content: string, config?: Partial<ToastItem>): void;
warning(content: string, config?: Partial<ToastItem>): void;
handleDismissed(index: number): void;
render(): JSX.Element[] | null;
}
export default ToastComponent;
interface ToastMessageState {
visible: boolean;
}
export declare class ToastMessage extends React.Component<ToastMessageProps, ToastMessageState> {
static defaultProps: Partial<ToastMessageProps>;
state: {
visible: boolean;
};
timer: ReturnType<typeof setTimeout>;
mounted: boolean;
componentDidMount(): void;
componentWillUnmount(): void;
handleMouseEnter(): void;
handleMouseLeave(): void;
handleEntered(): void;
close(): void;
render(): JSX.Element;
}
export declare const toast: {
container: any;
success: (content: string, confOrTitle?: Partial<ToastItem> | string) => void;
error: (content: string, confOrTitle?: Partial<ToastItem> | string) => void;
info: (content: string, confOrTitle?: Partial<ToastItem> | string) => void;
warning: (content: string, confOrTitle?: Partial<ToastItem> | string) => void;
};