import { JSX } from 'solid-js'; export type ToastType = 'success' | 'error' | 'loading' | 'blank' | 'custom'; export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; export type Renderable = JSX.Element | string | null; export type ValueFunction = (arg: TArg) => TValue; export type ValueOrFunction = TValue | ValueFunction; const isFunction = ( valOrFunction: ValueOrFunction ): valOrFunction is ValueFunction => typeof valOrFunction === 'function'; export const resolveValue = (valOrFunction: ValueOrFunction, arg: TArg): TValue => isFunction(valOrFunction) ? valOrFunction(arg) : valOrFunction; export interface IconTheme { primary?: string; secondary?: string; } export interface Toast { type: ToastType; id: string; message: ValueOrFunction; icon?: Renderable; duration?: number; pauseDuration: number; paused: boolean; position?: ToastPosition; ariaProps: { role: 'status' | 'alert'; 'aria-live': 'assertive' | 'off' | 'polite'; }; style?: JSX.CSSProperties; className?: string; iconTheme?: IconTheme; createdAt: number; updatedAt?: number; visible: boolean; height?: number; unmountDelay: number; } export type ToastOptions = Partial< Pick< Toast, 'id' | 'icon' | 'duration' | 'ariaProps' | 'className' | 'style' | 'position' | 'unmountDelay' | 'iconTheme' > >; export type ToastTimeouts = { [key in ToastType]: number; }; export type DefaultToastOptions = ToastOptions; export type Message = ValueOrFunction; export type ToastHandler = (message: Message, options?: ToastOptions) => string; export interface ToasterProps { position?: ToastPosition; toastOptions?: DefaultToastOptions; gutter?: number; containerStyle?: JSX.CSSProperties; containerClassName?: string; } export interface ToastContainerProps { toast: Toast; } export interface ToastBarProps { toast: Toast; position: ToastPosition; } export type IconProps = Partial;