@spicy-ui/core
Version:
A themable and extensible React UI library, ready to use out of the box
43 lines (42 loc) • 1.29 kB
TypeScript
import * as React from 'react';
import { ChildrenProp } from '../../types';
export declare enum ToastAction {
ADD = 0,
UPDATE = 1,
REMOVE = 2
}
export interface ToastReducerAction {
type: ToastAction;
toast: ToastComponentProps;
}
export declare type ToastId = string;
export declare type ToastMessage = React.ReactNode;
export declare type ToastPlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
export interface ToastOptions<P = any> {
id?: string;
message: ToastMessage;
props?: P;
duration?: number;
persist?: boolean;
}
export interface ToastContextProps<P = any> {
queueToast: (options: ToastOptions<P>) => ToastId;
closeToast: (id: ToastId) => void;
}
export interface ToastComponentProps<P = any> {
id: string;
isOpen: boolean;
message: ToastMessage;
props: P;
duration: number;
persist: boolean;
}
export declare function useToast(): ToastContextProps;
export interface ToastProviderProps extends ChildrenProp {
component: (props: ToastComponentProps) => JSX.Element;
duration?: number;
maxVisible?: number;
persist?: boolean;
placement?: ToastPlacement;
}
export declare const ToastProvider: React.FC<ToastProviderProps>;