0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,3 @@
export * from './useToastContainer';
export * from './useToast';
export * from './useKeeper';

View file

@ -0,0 +1,15 @@
import { Id } from '../types';
export declare const enum ActionType {
ADD = 0,
REMOVE = 1
}
export declare type State = Array<Id>;
export declare type Action = {
type: ActionType.ADD;
toastId: Id;
staleId?: Id;
} | {
type: ActionType.REMOVE;
toastId?: Id;
};
export declare function reducer(state: State, action: Action): Id[];

View file

@ -0,0 +1,7 @@
/**
* `useKeeper` is a helper around `useRef`.
*
* You don't need to access the `.current`property to get the value
* If refresh is set to true. The ref will be updated every render
*/
export declare function useKeeper<T>(arg: T, refresh?: boolean): T;

View file

@ -0,0 +1,10 @@
import { DOMAttributes } from 'react';
import { ToastProps } from '../types';
export declare function useToast(props: ToastProps): {
playToast: () => void;
pauseToast: () => void;
isRunning: boolean;
preventExitTransition: boolean;
toastRef: import("react").RefObject<HTMLDivElement>;
eventHandlers: DOMAttributes<HTMLElement>;
};

View file

@ -0,0 +1,16 @@
/// <reference types="react" />
import { Id, ToastContainerProps, Toast, ToastPosition } from '../types';
export interface ContainerInstance {
toastKey: number;
displayedToast: number;
props: ToastContainerProps;
containerId?: Id | null;
isToastActive: (toastId: Id) => boolean;
getToast: (id: Id) => Toast | null;
}
export declare function useToastContainer(props: ToastContainerProps): {
getToastToRender: <T>(cb: (position: ToastPosition, toastList: Toast[]) => T) => T[];
collection: Record<Id, Toast>;
containerRef: import("react").MutableRefObject<null>;
isToastActive: (id: Id) => boolean;
};