UNPKG

use-exit-intent

Version:
46 lines (43 loc) 1.5 kB
declare type DeepRequired<T> = { [K in keyof T]: Required<DeepRequired<T[K]>>; }; interface CookieOptions { key?: string; daysToExpire?: number; } interface DesktopOptions { triggerOnIdle?: boolean; triggerOnMouseLeave?: boolean; delayInSecondsToTrigger?: number; useBeforeUnload?: boolean; mouseLeaveDelayInSeconds?: number; } interface MobileOptions { triggerOnIdle?: boolean; delayInSecondsToTrigger?: number; } declare type InternalExitIntentSettings = Required<DeepRequired<ExitIntentSettings>>; interface ExitIntentSettings { cookie?: CookieOptions; desktop?: DesktopOptions; mobile?: MobileOptions; } declare type EventPrefix<T extends string> = `on${T}`; declare type Context = EventPrefix<'Trigger' | 'Unsubscribe' | 'Desktop' | 'Mobile'> | void | ''; interface ExitIntentHandler { id: string; handler: Function; context?: Context[]; } declare function useExitIntent(props?: ExitIntentSettings | void): { settings: Required<DeepRequired<ExitIntentSettings>>; resetState: () => void; isTriggered: boolean; unsubscribe: () => void; resetSettings: () => void; updateSettings: (settings?: ExitIntentSettings) => void; isUnsubscribed: boolean; registerHandler: (handler: ExitIntentHandler) => void; willBeTriggered: boolean; }; export { Context, CookieOptions, DeepRequired, DesktopOptions, ExitIntentHandler, ExitIntentSettings, InternalExitIntentSettings, MobileOptions, useExitIntent };