@itwin/core-react
Version:
A react component library of iTwin.js UI general purpose components
129 lines • 5.41 kB
TypeScript
/** @packageDocumentation
* @module Popup
*/
import "./Popup.scss";
import * as React from "react";
import { RelativePosition } from "@itwin/appui-abstract";
import type { CommonProps } from "../utils/Props.js";
/** @internal */
export declare const PopupContext: React.Context<HTMLElement | undefined>;
/** Properties for the [[Popup]] component
* @public
* @deprecated in 4.15.0. Props of deprecated {@link Popup} component.
*/
export interface PopupProps extends CommonProps {
/** Show or hide the box shadow (defaults to true) */
showShadow: boolean;
/** Show or hide the arrow (defaults to false) */
showArrow: boolean;
/** Indicates whether the popup is shown or not (defaults to false) */
isOpen: boolean;
/** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */
position: RelativePosition;
/** Top position (absolute positioning - defaults to 0) */
top: number;
/** Left position (absolute positioning - defaults to 0) */
left: number;
/** Function called when the popup is opened */
onOpen?: () => void;
/** Function called when user clicks outside the popup */
onOutsideClick?: (e: MouseEvent) => void;
/** Function called when the popup is closed */
onClose?: () => void;
/** Function called when the popup is closed on Enter */
onEnter?: () => void;
/** Function called when the wheel is used */
onWheel?: (e: WheelEvent) => void;
/** Function called when the right mouse button is pressed */
onContextMenu?: (e: MouseEvent) => void;
/** Offset from the parent (defaults to 4) */
offset: number;
/** Target element to position popup */
target?: HTMLElement | null;
/** Role - if not specified "dialog" is used */
role?: "dialog" | "alert" | "alertdialog";
/** accessibility label */
ariaLabel?: string;
/** set focus to popup - default to not set focus */
moveFocus?: boolean;
/** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */
focusTarget?: React.RefObject<HTMLElement | null> | string;
/** Indicates whether the popup is pinned. */
isPinned?: boolean;
/** Indicates whether to use animation for open/close (defaults to true) */
animate?: boolean;
/** Indicates whether to close the popup when Enter is pressed (defaults to true) */
closeOnEnter?: boolean;
/** Indicates whether to close the popup when the wheel is used (defaults to true) */
closeOnWheel?: boolean;
/** Indicates whether to close the popup when the right mouse button is pressed (defaults to true) */
closeOnContextMenu?: boolean;
/** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */
closeOnNestedPopupOutsideClick?: boolean;
/** If true the children are mounted once and unmounted when this component is unmounted. If false the
* children are unmounted each time the popup is closed. */
keepContentsMounted?: boolean;
/**
* If true the popup will remain open and will be repositioned when window resize events occur, default to false.
* @beta
* */
repositionOnResize?: boolean;
/** Content */
children?: React.ReactNode;
/** Target that should be used when portaling popup.
* @note This is needed in rare cases when {@link Popup} is nested inside the {@link https://itwinui.bentley.com/docs/popover iTwinUI Popover}.
*/
portalTarget?: HTMLElement;
}
interface PopupState {
isOpen: boolean;
top: number;
left: number;
position: RelativePosition;
parentDocument: Document;
animationEnded: boolean;
portalContainer?: HTMLElement;
}
/** Popup React component displays a popup relative to an optional target element.
* @note Avoid nesting {@link Popup} and {@link https://itwinui.bentley.com/docs/popover iTwinUI Popover} components.
* @public
* @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/popover iTwinUI Popover} instead.
*/
export declare class Popup extends React.Component<PopupProps, PopupState> {
private _popup;
/** @internal */
static contextType: React.Context<HTMLElement | undefined>;
/** @internal */
context: React.ContextType<typeof PopupContext>;
constructor(props: PopupProps);
static defaultProps: Partial<PopupProps>;
componentDidMount(): void;
private getParentWindow;
/** @internal */
componentDidUpdate(previousProps: PopupProps, // eslint-disable-line @typescript-eslint/no-deprecated
prevState: PopupState): void;
componentWillUnmount(): void;
private _bindWindowEvents;
private _unBindWindowEvents;
private _handleWheel;
private isInCorePopup;
private _handleOutsideClick;
private _handleContextMenu;
private _handleKeyboard;
private _resize;
private _hide;
private _onShow;
private _onClose;
private _isPositionAbsolute;
private _getClassNameByPosition;
private _getPopupDimensions;
private _getPosition;
private _toggleRelativePosition;
private _fitPopup;
private _handleAnimationEnd;
private _handleThemeProviderRef;
render(): React.ReactPortal | null;
private getContainer;
}
export {};
//# sourceMappingURL=Popup.d.ts.map