type ModalPopupConfig = { url?: string; onClose?: () => void; onOpen?: () => void; styles?: { container?: Record; content?: Record; iframe?: Record; }; sandbox?: string; allow?: string; }; /** * Represents a modal popup that can be opened and closed within a browser environment. * * The `ModalPopup` class allows for the creation and management of a modal window * that displays content from a specified URL. It supports dynamic URL construction * using path and query parameters, and provides hooks for custom actions on open * and close events. * * @property {string | null} modalUrl - The base URL for the modal content. * @property {() => void} onClose - Callback function executed when the modal is closed. * @property {() => void} onOpen - Callback function executed when the modal is opened. * @property {HTMLElement | null} modalElement - The DOM element representing the modal. * * @constructor * @param {ModalPopupConfig} cfg - Configuration object for initializing the modal popup. * * @method openPopup - Opens the modal with specified path and query parameters. * @method closePopup - Closes the currently open modal. * * @throws Will throw an error if the URL is not provided or if used outside a browser environment. */ declare class ModalPopup { private modalUrl; private onClose; private onOpen; private modalElementMap; private cfg; constructor(cfg: ModalPopupConfig); /** * Constructs a URL by replacing path parameters and appending query parameters. * * @param pathParams - An object containing key-value pairs to replace path placeholders in the URL. * @param queryParams - An object containing key-value pairs to be appended as query parameters. * @returns The constructed URL with path and query parameters. * @throws Error if the base URL is not set. */ private buildUrl; /** * Opens a modal popup by constructing a URL with the given path and query parameters. * If a modal is already open, it logs a warning and exits. * Throws an error if executed outside a browser environment. * * @param pathParams - An object containing key-value pairs to replace path placeholders in the URL. * @param queryParams - An object containing key-value pairs to be appended as query parameters. * @throws Error if not in a browser environment. */ openPopup(pathParams?: Record, queryParams?: Record): void; /** * Closes the currently open modal popup by removing it from the DOM. * Sets the modal element to null and triggers the onClose callback. */ closePopup(): void; /** * Represents a modal popup that can be opened and closed within a browser environment. * The modal is configured using a `ModalPopupConfig` object, which specifies the URL, * callbacks for open and close events, and optional styles. The modal content is loaded * in an iframe, and the modal can be closed by clicking outside the content or on a close button. * * The class ensures that only one modal is open at a time and provides methods to build * URLs with path and query parameters. It also handles cleanup before page reload. */ private applyStyles; /** * Creates and returns a modal element containing an iframe with the specified URL. * The modal includes a close button and is styled to cover the entire viewport. * Clicking outside the modal content or on the close button will close the modal. * * @param url - The URL to be loaded in the iframe within the modal. * @returns The constructed modal container element. */ private createModalElement; } /** * Creates and returns a new instance of a ModalPopup using the provided configuration. * * @param config - The configuration object for the modal popup. * @returns A new ModalPopup instance. */ declare function createModalPopup(config: ModalPopupConfig): ModalPopup; export { type ModalPopupConfig, createModalPopup };