import type { ReactNode } from "react"; /** * Describes an annotation to be rendered in the map's Controls overlay. * * Discriminated union on `type`: * - `"simple"`: icon + label + optional color -- rendered as a compact pill/badge * - `"custom"`: arbitrary ReactNode via render function -- full control */ export type MapAnnotationDescriptor = Readonly<{ type: "simple"; id: string; /** Lower number = higher priority in layout order */ priority?: number; icon?: ReactNode; label: string; color?: string; /** * When set, the pill is rendered as a button and the handler runs on click. * Implementations should call `stopPropagation` so multi-annotation stack * expand/pin toggles on the outer container are not triggered accidentally. */ onClick?: () => void; }> | Readonly<{ type: "custom"; id: string; /** Lower number = higher priority in layout order */ priority?: number; /** * Render function that returns the annotation's content. * * **Peek-card convention (`data-peek-root`):** * When multiple annotations are stacked, only the top card is fully * visible. Older annotations appear as narrow peek strips behind it. * To make peek strips show the correct background color, border-radius, * and shadow, place a `data-peek-root` attribute on the outermost * visual container element (the element that carries the background * and shape styles). Its direct children will be automatically hidden * via `visibility: hidden` when the annotation is rendered as a peek * strip, while the container's own appearance is preserved. * * If `data-peek-root` is omitted the peek strip still renders but * will show raw, unstyled content at 3 px height. */ render: () => ReactNode; }>; /** * Subscription-based store for map annotations. * Compatible with `useSyncExternalStore(subscribe, getSnapshot)`. * * Exposed on `MapApi.annotations` so consumers and Controls can * interact with annotations without React context indirection. * * The `claimRenderer` / `subscribeHasRenderer` / `getHasRendererSnapshot` * trio lets the Map component detect whether an external renderer (Controls) * has claimed annotation rendering. When unclaimed, the Map renders a * built-in fallback AnnotationStack. */ export type MapAnnotationStore = Readonly<{ register: (descriptor: MapAnnotationDescriptor) => void; unregister: (id: string) => void; subscribe: (callback: () => void) => () => void; getSnapshot: () => ReadonlyArray; claimRenderer: () => () => void; subscribeHasRenderer: (callback: () => void) => () => void; getHasRendererSnapshot: () => boolean; }>; /** * Creates a `MapAnnotationStore` instance. * * Uses a `Set<() => void>` for subscribers and a `Map` * for registered annotations. `getSnapshot` returns a stable `ReadonlyArray` reference * that only changes when annotations are mutated. * * @internal */ export declare const createMapAnnotationStore: () => MapAnnotationStore;