import type { Placement } from "@floating-ui/react"; import type { ShapeEntity } from "@trackunit/react-map-adapter-shared"; import type { RefCallback } from "react"; import type { EdgeLabelAnchor, EdgeLabelPlacementResolver } from "./edge/findBestEdgePosition"; import type { ShapeDecoration } from "./shapeDecorations"; import type { ResolveShapeLabel } from "./shapeLabelResolution"; /** * Create an edge-auto decoration that places a flush label on the best visible * edge of a polygon or line. Returns `undefined` when `label` is nullish, so * it can be used directly in a `getDecorations` array and filtered automatically. * * @example * ```tsx * const zones = useShapes({ * id: "zones", * features: zoneFeatureCollection, * resolveStyle: () => ({ stroke: "blue" }), * getDecorations: (f) => [ * edgeLabel(f.properties?.name as string | undefined), * ], * }); * ``` */ export declare const edgeLabel: (label: string | undefined | null, options?: Readonly<{ interactive?: boolean; onClick?: (entity: ShapeEntity) => void; onHover?: (entity: ShapeEntity | null) => void; resolveLabel?: ResolveShapeLabel; labelAnchor?: EdgeLabelAnchor; /** * Custom placement resolver. When omitted, the default resolver is used. * The resolver receives `context.isForced = true` on the forced retry pass * (when no edge fit the label), allowing anchor or side changes without a * separate option. */ labelPlacementResolver?: EdgeLabelPlacementResolver; /** * Forwarded to `ShapeDecoration.panelAnchorRef`. The edge-label portal * container element is passed to this callback so a panel can anchor to it. */ panelAnchorRef?: RefCallback; /** * Forwarded to `ShapeDecoration.onEdgePlacement`. Called with the outward * Floating UI `Placement` when the label is placed on an edge. */ onEdgePlacement?: (placement: Placement) => void; }>) => ShapeDecoration | undefined;