export declare type BeforeResizeContext = { iframe: HTMLIFrameElement; settings: Settings; observedHeight: number; interactionState: InteractionState; }; export declare type IframeChildInitEventData = { type: "iframe-child-init"; targetElementSelector?: string; bodyPadding?: string; bodyMargin?: string; }; export declare type IframeGetChildDimensionsEventData = { type: "iframe-get-child-dimensions"; }; export declare type IframeResizeEvent = MessageEvent; export declare type IframeResizeEventData = { type: "iframe-resized"; width: number; height?: number; }; export declare const initialize: InitializeFunction; export declare function initializeChildListener(): void; /** * Automatically resize the selected iframes when their inner content grows. * @param settings The settings for the selected iframes. The default settings properties are picked if empty. * @param selector The selector for the iframe(s) or the HTMLIFrameElement to be resized. If empty, all document iframe elements will be selected. * @returns A result array Promise, which can be used to clean up the listeners if you remove iframes from the document and want to clean all associated listeners. */ export declare type InitializeFunction = (settings?: Partial, selector?: string | HTMLIFrameElement) => Promise; export declare type InitializeResult = { unsubscribe: () => void; resize: () => void }; export declare type InteractionState = { isHovered: boolean; }; export declare type RegisteredElement = { iframe: HTMLIFrameElement; settings: Settings; interactionState: InteractionState; initContext: { isInitialized: boolean; retryAttempts: number; retryTimeoutId?: number }; }; export declare type ResizeContext = { iframe: HTMLIFrameElement; settings: Settings; interactionState: InteractionState; previousRenderState: ResizeRenderState; nextRenderState: ResizeRenderState; }; export declare type ResizeRenderState = { rect: DOMRect }; export declare type Settings = { /** * Offset added to the resize size (in pixels). * * Default: `0` */ offsetSize: number; /** * Specifies whether to check the origin of incoming messages. * Accepts an array of allowed origins or a boolean. * If `true`, incoming messages are allowed from the origins of the registered iframes. * * Default: `true` */ checkOrigin: string[] | boolean; /** * Allows the library to communicate with a cross-origin child iframe * containing the original "iframe-resizer" script. * Useful if you do not control the child domain. * * Default: `false` */ enableLegacyLibSupport: boolean; /** * By default, the root element observed for resizing is the document. * In more complex layouts, the scrolling container may be elsewhere. * This setting allows you to customize the root element that should be observed for resize events. * * Default: `undefined` */ targetElementSelector?: string; /** * Customize the padding style of the iframe body. * * Default: `undefined` */ bodyPadding?: string; /** * Customize the margin style of the iframe body. * * Default: `undefined` */ bodyMargin?: string; /** * Called whenever the observed content size changes and the iframe is about to be resized. * Return `false` to cancel the resize; returning `true` or nothing will allow it. * * Default: `undefined` */ onBeforeIframeResize?: (context: BeforeResizeContext) => boolean | undefined; /** * Listener that is called after the iframe has been resized. * You can use a predefined handler like `updateParentScrollOnResize` or create your own custom handler. * * Default: `undefined` */ onIframeResize?: (context: ResizeContext) => void; }; /** * Resize handler that scrolls to restore the iframe's position in the viewport as it was before the resize. * * *Note:* This behavior only triggers if the iframe currently has focus, * in order to try to limit the number of scroll as it can affect the user experience. */ export declare const updateParentScrollOnResize: ({ previousRenderState, nextRenderState, iframe }: ResizeContext) => void; export { }