UNPKG

rooks

Version:

Collection of awesome react hooks

68 lines (67 loc) 2.46 kB
interface ScreenDetailed { availLeft: number; availTop: number; availWidth: number; availHeight: number; left: number; top: number; width: number; height: number; colorDepth: number; pixelDepth: number; devicePixelRatio: number; isPrimary: boolean; isInternal: boolean; label: string; addEventListener: (event: string, handler: (event: Event) => void) => void; removeEventListener: (event: string, handler: (event: Event) => void) => void; } interface ScreenDetails { screens: ScreenDetailed[]; currentScreen: ScreenDetailed; addEventListener: (event: string, handler: (event: Event) => void) => void; removeEventListener: (event: string, handler: (event: Event) => void) => void; } interface UseScreenDetailsApiOptions { /** * Whether to automatically request permission on mount * @default false */ requestOnMount?: boolean; /** * Whether to automatically refresh screen details on events * @default true */ autoRefresh?: boolean; } interface UseScreenDetailsApiReturn { /** Array of all available screens */ screens: ScreenDetailed[]; /** Current screen where the browser window is displayed */ currentScreen: ScreenDetailed | null; /** Primary screen (the main display) */ primaryScreen: ScreenDetailed | null; /** External screens (non-primary screens) */ externalScreens: ScreenDetailed[]; /** Whether the Screen Details API is supported */ isSupported: boolean; /** Whether the hook is currently loading screen details */ isLoading: boolean; /** Whether permission has been granted */ hasPermission: boolean; /** Error message if any operation failed */ error: string | null; /** Request permission to access screen details */ requestPermission: () => Promise<void>; /** Manually refresh screen details */ refresh: () => Promise<void>; } /** * Hook for multi-screen information and management using Screen Details API * @param options Configuration options for the hook * @returns Object containing screen details and control functions * @see {@link https://rooks.vercel.app/docs/hooks/useScreenDetailsApi} */ declare function useScreenDetailsApi(options?: UseScreenDetailsApiOptions): UseScreenDetailsApiReturn; export { useScreenDetailsApi }; export type { UseScreenDetailsApiOptions, UseScreenDetailsApiReturn, ScreenDetailed, ScreenDetails };