UNPKG

4.71 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, IRef } from "../../common";
3import { IPopoverSharedProps } from "./popoverSharedProps";
4export declare const PopoverInteractionKind: {
5 CLICK: "click";
6 CLICK_TARGET_ONLY: "click-target";
7 HOVER: "hover";
8 HOVER_TARGET_ONLY: "hover-target";
9};
10export declare type PopoverInteractionKind = typeof PopoverInteractionKind[keyof typeof PopoverInteractionKind];
11export interface IPopoverProps extends IPopoverSharedProps {
12 /** HTML props for the backdrop element. Can be combined with `backdropClassName`. */
13 backdropProps?: React.HTMLProps<HTMLDivElement>;
14 /**
15 * The content displayed inside the popover. This can instead be provided as
16 * the _second_ element in `children` (first is `target`).
17 */
18 content?: string | JSX.Element;
19 /**
20 * Whether the wrapper and target should take up the full width of their container.
21 * Note that supplying `true` for this prop will force `targetTagName="div"` and
22 * `wrapperTagName="div"`.
23 */
24 fill?: boolean;
25 /**
26 * The kind of interaction that triggers the display of the popover.
27 *
28 * @default PopoverInteractionKind.CLICK
29 */
30 interactionKind?: PopoverInteractionKind;
31 /**
32 * Enables an invisible overlay beneath the popover that captures clicks and
33 * prevents interaction with the rest of the document until the popover is
34 * closed. This prop is only available when `interactionKind` is
35 * `PopoverInteractionKind.CLICK`. When popovers with backdrop are opened,
36 * they become focused.
37 *
38 * @default false
39 */
40 hasBackdrop?: boolean;
41 /**
42 * Whether the application should return focus to the last active element in the
43 * document after this popover closes.
44 *
45 * This is automatically set to `false` if this is a hover interaction popover.
46 *
47 * If you are attaching a popover _and_ a tooltip to the same target, you must take
48 * care to either disable this prop for the popover _or_ disable the tooltip's
49 * `openOnTargetFocus` prop.
50 *
51 * @default false
52 */
53 shouldReturnFocusOnClose?: boolean;
54 /**
55 * Ref supplied to the `Classes.POPOVER` element.
56 */
57 popoverRef?: IRef<HTMLElement>;
58 /**
59 * The target to which the popover content is attached. This can instead be
60 * provided as the _first_ element in `children`.
61 */
62 target?: string | JSX.Element;
63}
64export interface IPopoverState {
65 transformOrigin: string;
66 isOpen: boolean;
67 hasDarkParent: boolean;
68}
69/** @deprecated use { Popover2 } from "@blueprintjs/popover2" */
70export declare class Popover extends AbstractPureComponent2<IPopoverProps, IPopoverState> {
71 static displayName: string;
72 private popoverRef;
73 static defaultProps: IPopoverProps;
74 /**
75 * DOM element that contains the popover.
76 * When `usePortal={true}`, this element will be portaled outside the usual DOM flow,
77 * so this reference can be very useful for testing.
78 */
79 popoverElement: HTMLElement | null;
80 /** DOM element that contains the target. */
81 targetElement: HTMLElement | null;
82 state: IPopoverState;
83 private cancelOpenTimeout?;
84 private isMouseInTargetOrPopover;
85 private lostFocusOnSamePage;
86 private popperScheduleUpdate?;
87 private handlePopoverRef;
88 private handleTargetRef;
89 render(): JSX.Element;
90 componentDidMount(): void;
91 componentDidUpdate(prevProps: IPopoverProps, prevState: IPopoverState): void;
92 /**
93 * Instance method to instruct the `Popover` to recompute its position.
94 *
95 * This method should only be used if you are updating the target in a way
96 * that does not cause it to re-render, such as changing its _position_
97 * without changing its _size_ (since `Popover` already repositions when it
98 * detects a resize).
99 */
100 reposition: () => void | undefined;
101 protected validateProps(props: IPopoverProps & {
102 children?: React.ReactNode;
103 }): void;
104 private updateDarkParent;
105 private renderPopover;
106 private renderTarget;
107 private understandChildren;
108 private isControlled;
109 private getIsOpen;
110 private getPopperModifiers;
111 private handleTargetFocus;
112 private handleTargetBlur;
113 private handleMouseEnter;
114 private handleMouseLeave;
115 private handlePopoverClick;
116 private handleOverlayClose;
117 private handleTargetClick;
118 private setOpenState;
119 private isArrowEnabled;
120 private isElementInPopover;
121 private isHoverInteractionKind;
122 /** Popper modifier that updates React state (for style properties) based on latest data. */
123 private updatePopoverState;
124}