import { default as EventEmitter } from './EventEmitter'; import { ModalComponent, ModalParams } from './types'; interface ModalWindowEvents { open(): void; close(): void; } declare class ModalWindow { /** * Hash of `serialized` property. * * Unique id of the modal window. * If two modals have the same id, they will be treated as the same modal. * * This is usually used in `key` prop for React components. * * @note * This is not the same as `params.id` because `id` is unique for each modal window. */ readonly id: number; /** * String representation of `component` and `params`. */ readonly serialized: string; component: ModalComponent; params: ModalParams & CustomParams; /** * Indicates that the `close` method has been called and the modal window is going to be removed. * * @default * false */ closed: boolean; protected events: EventEmitter; private deffered; constructor(component: ModalComponent, params: Partial & CustomParams); /** * Closes the modal window. * * @note * This is an arrow function, which prevents `this` from being lost - You can use it without `bind`. * * @example * const modal = Modal.open(PopupHello, { title: "Hello" }) * modal.close() */ close: () => void; /** * Can be used to wait for the modal to be closed before performing an action. * * @example * await Modal.open(PopupHello, { title: "Hello" }) * doAnyAction() */ then(onfulfilled?: ((value: void) => void | PromiseLike) | undefined | null, onrejected?: ((reason: unknown) => void | PromiseLike) | undefined | null): PromiseLike; /** * Subscribes to `event` with `listener`. * @example * const modal = Modal.open(PopupHello, { title: "Hello" }) * modal.on("close", () => { }) * * @note If you want to do something on close, you can use await directly on this instance. For details see `then` method in `ModalWindow`. * * @returns `unsubscribe` method */ on(event: K, listener: ModalWindowEvents[K]): () => void; } /** * This is a workaround for TypeScript. * * Used if it doesn't matter what type of `CustomParams` is used. */ export type ModalWindowAny = ModalWindow; export { ModalWindow };