import type { RefObject } from "react"; import type { ContainerRefHolder } from "./types"; /** * Narrow structural type for the keyboard navigation hook. * Contains only the stable properties the hook actually reads: * - `actions.panBy` and `actions.zoomBy` (stable — memoized on adapter) * - `containerRef` (stable — created via useState) * * `MapApi` satisfies this type via structural subtyping, so consumers * can pass `api` from `useMap()` directly without any assertion. */ export type MapKeyboardNavigationApi = Readonly<{ actions: Readonly<{ panBy: (deltaX: number, deltaY: number) => Promise; zoomBy: (delta: number) => Promise; }>; containerRef: ContainerRefHolder; }>; /** * Opt-in keyboard navigation hook for map components. * Provides consistent keyboard shortcuts: * - Arrow keys: Pan the map in all directions * - `=` key: Zoom in * - `-` key: Zoom out * * **Usage:** * ```tsx * import { useMap, useMapKeyboardNavigation } from "@trackunit/react-map"; * import { googleMapsAdapter } from "@trackunit/react-map-adapter-google"; * * const [Map, api] = useMap(googleMapsAdapter({ apiKey })); * useMapKeyboardNavigation(api); * ``` * * @param api - The map API object (or any object matching `MapKeyboardNavigationApi`) * @param containerRef - Optional override for the keyboard event target. Defaults to `api.containerRef`. */ export declare const useMapKeyboardNavigation: (api: MapKeyboardNavigationApi, containerRef?: RefObject) => void;