UNPKG

@tinacms/toolkit

Version:

Tina is a lightweight but powerful toolkit for creating a site editing ui with javascript components. Tina surfaces superpowers for dev’s to create, expand on and customize a simple yet intuitive ui for editing content.

38 lines (36 loc) 1.3 kB
/** */ import React from 'react'; import { EventBus, Callback, CMSEvent } from '../../packages/core'; export interface EventsToAlerts { [key: string]: ToAlert | AlertArgs; } export declare type ToAlert = (event: CMSEvent) => AlertArgs; export interface AlertArgs { level: AlertLevel; message: string; timeout?: number; } export declare class Alerts { private events; private map; private alerts; private mapEventToAlert; constructor(events: EventBus, map?: EventsToAlerts); setMap(eventsToAlerts: EventsToAlerts): void; add(level: AlertLevel, message: string | React.FunctionComponent, timeout?: number): () => void; dismiss(alert: Alert): void; subscribe(cb: Callback): () => void; get all(): Alert[]; info(message: string | React.FunctionComponent, timeout?: number): () => void; success(message: string | React.FunctionComponent, timeout?: number): () => void; warn(message: string | React.FunctionComponent, timeout?: number): () => void; error(message: string | React.FunctionComponent, timeout?: number): () => void; } export declare type AlertLevel = 'info' | 'success' | 'warn' | 'error'; export interface Alert { id: string; level: AlertLevel; message: string | React.FunctionComponent; timeout: number; }