import type { Placement } from "@floating-ui/react"; /** * Context passed to `resolveAutoPan` when an anchored panel first commits. * * `clipping` values are positive when the panel overflows the map container * on that side (e.g. `clipping.right = 20` means the panel extends 20 px * beyond the container's right edge). * * `panelScrollHeight` is the natural content height of the panel's inner scroll * div — equal to `panelRect.height` when content fits, greater when the panel * is scroll-constrained. Combined with `panelCssMaxHeight`, this lets resolvers * compute how much panning would eliminate (or reduce) scrolling. * * `panelCssMaxHeight` is the effective CSS `max-height` cap on the panel shell * (`min(320px, 40vh)` evaluated at commit time). Panning beyond what's needed * to reach this cap does not reduce scrolling further. */ export type AutoPanContext = Readonly<{ panelRect: DOMRect; anchorRect: DOMRect; containerRect: DOMRect; placement: Placement; clipping: Readonly<{ top: number; right: number; bottom: number; left: number; }>; /** Natural content height of the inner scroll div (from `scrollHeight`). */ panelScrollHeight: number; /** Effective CSS `max-height` on the panel shell at commit time. */ panelCssMaxHeight: number; }>; /** * Return value from `resolveAutoPan`. * * `x` and `y` are screen-space pixel offsets for `api.actions.panBy`: * - positive x = pan map right (content moves left) * - positive y = pan map down (content moves up) * * Return `null` to skip panning (panel already fits). * * When `restoreOnDismiss` is `true` (or omitted), `usePanel` captures the * map center before panning and calls `panTo(capturedCenter)` when the panel * is dismissed — returning the viewport to its pre-pan position. * Set to `false` to opt out of the restore. */ export type AutoPanResult = Readonly<{ x: number; y: number; restoreOnDismiss?: boolean; }> | null; /** * Default auto-pan resolver: pans the minimum amount to give the panel the * best possible screen space. Handles two cases: * * 1. **Clipping** — panel bleeds outside the map container on any side. Pans * to clear the bleed with 12 px of breathing room. * * 2. **Scroll-squish** — panel is within the container but shift-pressed against * an edge, so content overflows and the panel scrolls. Pans to give the panel * room to grow, up to the CSS `max-height` cap (`panelCssMaxHeight`). * * Returns `null` when the panel already fits without scrolling and without * clipping — meaning no pan is needed. * * Pass as `resolveAutoPan` to {@link usePanel} for the standard behavior: * * ```tsx * usePanel(api, { * id: "my-panel", * open: isOpen, * resolveAutoPan: defaultAutoPanResolver, * children: , * }); * ``` */ export declare const defaultAutoPanResolver: (ctx: AutoPanContext) => AutoPanResult;