/** * A handle for an open dialog that can be used to interact with it. * * @remarks * * Dialogs can be opened using either {@link DialogApi.show} or {@link DialogApi.showModal}. * * @public */ export interface DialogApiDialog { /** * Closes the dialog with that provided result. * * @remarks * * If the dialog is a modal dialog a result must always be provided. If it's a regular dialog then passing a result is optional. */ close(...args: undefined extends TResult ? [result?: TResult] : [result: TResult]): void; /** * Replaces the content of the dialog with the provided element or component, causing it to be rerenedered. */ update(elementOrComponent: React.JSX.Element | ((props: { dialog: DialogApiDialog; }) => JSX.Element)): void; /** * Wait until the dialog is closed and return the result. * * @remarks * * If the dialog is a modal dialog a result will always be returned. If it's a regular dialog then the result may be `undefined`. */ result(): Promise; } /** * A Utility API for showing dialogs that render in the React tree and return a result. * * @public */ export interface DialogApi { /** * Opens a modal dialog and returns a handle to it. * * @remarks * * This dialog can be closed by calling the `close` method on the returned handle, optionally providing a result. * The dialog can also be closed by the user by clicking the backdrop or pressing the escape key. * * If the dialog is closed without a result, the result will be `undefined`. * * @example * * ### Example with inline dialog content * ```tsx * const dialog = dialogApi.show( * * Are you sure? * * * * * * ); * const result = await dialog.result(); * ``` * * @example * * ### Example with separate dialog component * ```tsx * function CustomDialog({ dialog }: { dialog: DialogApiDialog }) { * return ( * * Are you sure? * * * * * * ) * } * const result = await dialogApi.show(CustomDialog).result(); * ``` * * @param elementOrComponent - The element or component to render in the dialog. If a component is provided, it will be provided with a `dialog` prop that contains the dialog handle. * @public */ show(elementOrComponent: JSX.Element | ((props: { dialog: DialogApiDialog; }) => JSX.Element)): DialogApiDialog; /** * Opens a modal dialog and returns a handle to it. * * @remarks * * This dialog can not be closed in any other way than calling the `close` method on the returned handle and providing a result. * * @example * * ### Example with inline dialog content * ```tsx * const dialog = dialogApi.showModal( * * Are you sure? * * * * * * ); * const result = await dialog.result(); * ``` * * @example * * ### Example with separate dialog component * ```tsx * function CustomDialog({ dialog }: { dialog: DialogApiDialog }) { * return ( * * Are you sure? * * * * * * ) * } * const result = await dialogApi.showModal(CustomDialog).result(); * ``` * * @param elementOrComponent - The element or component to render in the dialog. If a component is provided, it will be provided with a `dialog` prop that contains the dialog handle. * @public */ showModal(elementOrComponent: JSX.Element | ((props: { dialog: DialogApiDialog; }) => JSX.Element)): DialogApiDialog; } /** * The `ApiRef` of {@link DialogApi}. * * @public */ export declare const dialogApiRef: import("@backstage/core-plugin-api").ApiRef;