UNPKG

preact-spatial-navigation

Version:

A powerful Preact library for TV-style spatial navigation with LRUD algorithm, virtualized lists/grids, and smart TV support

54 lines 1.69 kB
import type { JSX, Ref } from 'preact'; /** * Device types supported by the library * remoteKeys - using remote control with arrow keys * remotePointer - using remote control with pointer (e.g., Magic Remote) */ export type DeviceType = 'remoteKeys' | 'remotePointer' | 'tv' | 'desktop' | 'mobile' | 'tablet'; /** * Device type context value */ export interface DeviceTypeContextValue { deviceType: DeviceType; deviceTypeRef: Ref<DeviceType>; setDeviceType: (deviceType: DeviceType) => void; setScrollingIntervalId: (id: NodeJS.Timeout | null) => void; isTv: boolean; isDesktop: boolean; isMobile: boolean; isTablet: boolean; } /** * Props for SpatialNavigationDeviceTypeProvider */ export interface SpatialNavigationDeviceTypeProviderProps { /** Device type - can be manually specified or auto-detected */ deviceType?: DeviceType; /** Children elements */ children: JSX.Element | JSX.Element[]; } /** * SpatialNavigationDeviceTypeProvider - Provides device type context * Detects or accepts device type and provides it to child components */ export declare function SpatialNavigationDeviceTypeProvider({ deviceType: providedDeviceType, children, }: SpatialNavigationDeviceTypeProviderProps): JSX.Element; /** * Hook to access device type context * * @returns Device type context value * * @example * ```tsx * function MyComponent() { * const { isTv, deviceType } = useDeviceType(); * * return ( * <div> * {isTv ? 'TV Interface' : 'Standard Interface'} * </div> * ); * } * ``` */ export declare function useDeviceType(): DeviceTypeContextValue; //# sourceMappingURL=DeviceTypeContext.d.ts.map