rooks
Version:
Essential React custom hooks ⚓ to super charge your components!
48 lines • 1.52 kB
TypeScript
interface IdleDetector extends EventTarget {
userState: "active" | "idle" | null;
screenState: "locked" | "unlocked" | null;
start(options?: {
threshold?: number;
signal?: AbortSignal;
}): Promise<void>;
addEventListener(type: "change", listener: () => void): void;
removeEventListener(type: "change", listener: () => void): void;
}
interface IdleDetectorConstructor {
new (): IdleDetector;
requestPermission(): Promise<"granted" | "denied">;
}
declare global {
interface Window {
IdleDetector?: IdleDetectorConstructor;
}
}
interface UseIdleDetectionApiOptions {
threshold?: number;
autoStart?: boolean;
requestPermission?: boolean;
onIdleChange?: (state: {
isIdle: boolean;
userState: "active" | "idle";
screenState: "locked" | "unlocked";
}) => void;
onError?: (error: Error) => void;
}
interface UseIdleDetectionApiReturn {
isIdle: boolean;
userState: "active" | "idle";
screenState: "locked" | "unlocked";
isSupported: boolean;
isPermissionGranted: boolean;
start: () => Promise<void>;
stop: () => void;
}
/**
* useIdleDetectionApi hook - Detects when user is idle using Idle Detection API with polyfill
*
* @param options Configuration options
* @returns Object with idle state and control methods
*/
export declare function useIdleDetectionApi(options?: UseIdleDetectionApiOptions): UseIdleDetectionApiReturn;
export {};
//# sourceMappingURL=useIdleDetectionApi.d.ts.map