@ui5/webcomponents-react
Version:
React Wrapper for UI5 Web Components and additional components
89 lines (88 loc) • 4.46 kB
TypeScript
import type { MutableRefObject } from 'react';
import type { DialogDomRef, DialogPropTypes } from '../../webComponents/Dialog/index.js';
import type { MenuDomRef, MenuPropTypes } from '../../webComponents/Menu/index.js';
import type { PopoverDomRef, PopoverPropTypes } from '../../webComponents/Popover/index.js';
import type { ResponsivePopoverDomRef, ResponsivePopoverPropTypes } from '../../webComponents/ResponsivePopover/index.js';
import type { ToastDomRef, ToastPropTypes } from '../../webComponents/Toast/index.js';
import type { MessageBoxPropTypes } from '../MessageBox/index.js';
/**
* @since 2.19.0
*/
interface ModalConfig {
/**
* Optional container where the component should be mounted.
*
* @default `document.body`
*/
container?: Element | DocumentFragment;
}
/**
* @since 2.19.0
*/
interface ModalConfigPopover extends ModalConfig {
/**
* If set to `true`, opening a new Popover will automatically close all currently opened Popovers that share the __same opener__.
*
* __Note:__
* - This only affects `Popover`, `Menu`, and `ResponsivePopover`.
* - Only closes open Popovers with the __same opener__.
*/
autoClosePopovers?: boolean;
}
type ModalReturnType<DomRef> = {
ref: MutableRefObject<DomRef>;
};
type ClosableModalReturnType<DomRef> = ModalReturnType<DomRef> & {
close: () => void;
};
declare function showDialogFn(props: DialogPropTypes, config?: ModalConfig): ClosableModalReturnType<DialogDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showDialogFn(props: DialogPropTypes, container?: Element | DocumentFragment): ClosableModalReturnType<DialogDomRef>;
declare function showPopoverFn(props: PopoverPropTypes, config?: ModalConfigPopover): ClosableModalReturnType<PopoverDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showPopoverFn(props: PopoverPropTypes, container?: Element | DocumentFragment): ClosableModalReturnType<PopoverDomRef>;
declare function showResponsivePopoverFn(props: ResponsivePopoverPropTypes, config?: ModalConfigPopover): ClosableModalReturnType<ResponsivePopoverDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showResponsivePopoverFn(props: ResponsivePopoverPropTypes, container?: Element | DocumentFragment): ClosableModalReturnType<ResponsivePopoverDomRef>;
declare function showMenuFn(props: MenuPropTypes, config?: ModalConfigPopover): ClosableModalReturnType<MenuDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showMenuFn(props: MenuPropTypes, container?: Element | DocumentFragment): ClosableModalReturnType<MenuDomRef>;
declare function showMessageBoxFn(props: MessageBoxPropTypes, config?: ModalConfig): ClosableModalReturnType<DialogDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showMessageBoxFn(props: MessageBoxPropTypes, container?: Element | DocumentFragment): ClosableModalReturnType<DialogDomRef>;
declare function showToastFn(props: ToastPropTypes, config?: ModalConfig): ModalReturnType<ToastDomRef>;
/**
* @deprecated Passing `container` directly is deprecated. Use the `config` object with `config.container` instead.
*/
declare function showToastFn(props: ToastPropTypes, container?: Element | DocumentFragment): ModalReturnType<ToastDomRef>;
/**
* Utility class for opening modals in an imperative way.
*
* These static helper methods might be useful for showing e.g. Toasts or MessageBoxes after successful or failed
* network calls.
*
* **In order to use these helpers, please make sure to render the `Modals` component somewhere in your application tree.**
*
* @since 0.22.2
*/
export declare function Modals(): import("react").JSX.Element;
export declare namespace Modals {
var displayName: string;
var showDialog: typeof showDialogFn;
var showPopover: typeof showPopoverFn;
var showResponsivePopover: typeof showResponsivePopoverFn;
var showMenu: typeof showMenuFn;
var showMessageBox: typeof showMessageBoxFn;
var showToast: typeof showToastFn;
}
export {};