import React from 'react' import type { ToastLayout, Toast } from '../use-toasts/use-toast' export const defaultToastLayout: Required = { padding: '12px 16px', margin: '8px 0', width: '420px', maxWidth: '90vw', maxHeight: '75px', placement: 'bottomRight' } export type UpdateToastsFunction = (fn: (toasts: Array) => Array) => any export type UpdateToastsLayoutFunction = ( fn: (layout: Required) => Required ) => any export type UpdateToastsIDFunction = (fn: () => string | null) => any export interface HuiContextParams { toasts: Array updateToasts: UpdateToastsFunction toastLayout: Required updateToastLayout: UpdateToastsLayoutFunction lastUpdateToastId: string | null updateLastToastId: UpdateToastsIDFunction } const defaultParams: HuiContextParams = { toasts: [], toastLayout: defaultToastLayout, updateToastLayout: (t) => t, updateToasts: (t) => t, lastUpdateToastId: null, updateLastToastId: () => null } export const HuiContent: React.Context = React.createContext(defaultParams) export const useHuiContext = (): HuiContextParams => React.useContext(HuiContent)