import { type ReactNode, type Ref } from "react"; /** A part's rectangle, in points relative to the AnatomyProvider's own box. */ export interface AnatomyRect { x: number; y: number; width: number; height: number; } /** Every measured part's rectangle, by part name (a part not on screen is absent). */ export type AnatomyRects = Readonly>; /** What a component spreads on the host node that draws a part. */ export interface AnatomyTarget { ref: (node: unknown) => void; onLayout: () => void; } /** * The hand-off's anatomy zoom for a component that hugs its content (Component.dc.html * line 412: `anZoom:fill?'1':'1.6'`); a fill component is drawn at 1. */ export declare const ANATOMY_ZOOM = 1.6; /** * A rectangle measured in the layout space of a box that is then scaled by `scale` about * its own centre, mapped into the space the box is seen in: x' = cx + (x - cx) * s, y' = * cy + (y - cy) * s, w' = w * s, h' = h * s, with (cx, cy) the centre of `inner`, the box * carrying the transform, in the same space as `rect`. */ export declare function zoomRect(rect: AnatomyRect, inner: AnatomyRect, scale: number): AnatomyRect; /** The handlers for part `name` inside an AnatomyProvider, undefined outside one. */ export declare function useAnatomyPart(name: string): AnatomyTarget | undefined; /** * Closes the registry to everything inside it: a component renders its tree inside one * after taking its own parts' handlers, so the kit components and caller content within * it register nothing of theirs. Outside a provider it renders its children bare. */ export declare function AnatomyScope({ children }: { children?: ReactNode; }): ReactNode; /** AnatomyPart's props: the part by `name`, or the handlers a component took for it above its AnatomyScope. */ export type AnatomyPartProps = { name: string; part?: never; children?: ReactNode; } | { part: AnatomyTarget | undefined; name?: never; children?: ReactNode; }; /** * Registers an element the component cannot ref (an icon slot, a caller's child, a kit * component it renders) as a part: inside an AnatomyProvider it renders the element in a * measuring view, outside one it renders the element bare. `name` registers the part * itself; `part` takes the handlers the component took with `useAnatomyPart` before its * AnatomyScope, so the element is measured below the scope. */ export declare function AnatomyPart(props: AnatomyPartProps): ReactNode; /** Compose a part's layout handler with a host node's own. */ export declare function withPartLayout(part: AnatomyTarget | undefined, own: ((event: E) => void) | undefined): ((event: E) => void) | undefined; /** * A host node's forwarded ref joined with an anatomy part's: the forwarded ref itself when * there is no part (outside an AnatomyProvider, or inside a closing AnatomyScope), the * part's ref when nothing was forwarded, and otherwise one stable callback feeding both. * The hook-free counterpart of useComposedRefs for the kit primitives, which render on * every screen and take no hook for a part outside a provider. */ export declare function withPartRef(part: AnatomyTarget | undefined, ref: Ref | undefined): Ref | undefined; export interface AnatomyProviderProps { /** * Called with every registered part's rectangle, relative to the provider's box and in * the space the specimen is seen in, each time one is measured anew or leaves the * screen, together with the provider's own box as its parent laid it out, so a consumer * drawing markers places them against one source. */ onMeasure?: (parts: AnatomyRects, box: AnatomyRect) => void; /** * Draw the specimen at the hand-off's anatomy zoom (1.6, a component that hugs its * content); without it the specimen is drawn at its natural size (a fill component). */ zoomed?: boolean; /** The specimen whose parts register. */ children?: ReactNode; } /** * Collects the named parts of the components inside it (Button's `Container`, `Label`, * `Leading icon`, `Trailing icon` and `Count badge`) with their rectangles relative to * its own box, for a docs Anatomy section to number. It renders one view, the box the * rectangles are relative to, filling its stage and centring the specimen as the * hand-off's specimen box does (Component.dc.html line 218, `width:100%;display:flex; * justify-content:center`), so markers drawn as its absolutely positioned children, or * over it from the box it reports, line up with the parts. */ export declare function AnatomyProvider({ onMeasure, zoomed, children }: AnatomyProviderProps): ReactNode; //# sourceMappingURL=anatomy.d.ts.map