1 | import { Boundary, Modifier, Placement, placements, RootBoundary, StrictModifiers } from "@popperjs/core";
|
2 | import * as React from "react";
|
3 | import { StrictModifier } from "react-popper";
|
4 | import { Props } from "../../common";
|
5 | import { OverlayableProps } from "../overlay/overlay";
|
6 | export declare const PopoverPosition: {
|
7 | AUTO: "auto";
|
8 | AUTO_END: "auto-end";
|
9 | AUTO_START: "auto-start";
|
10 | BOTTOM: "bottom";
|
11 | BOTTOM_LEFT: "bottom-left";
|
12 | BOTTOM_RIGHT: "bottom-right";
|
13 | LEFT: "left";
|
14 | LEFT_BOTTOM: "left-bottom";
|
15 | LEFT_TOP: "left-top";
|
16 | RIGHT: "right";
|
17 | RIGHT_BOTTOM: "right-bottom";
|
18 | RIGHT_TOP: "right-top";
|
19 | TOP: "top";
|
20 | TOP_LEFT: "top-left";
|
21 | TOP_RIGHT: "top-right";
|
22 | };
|
23 | export type PopoverPosition = (typeof PopoverPosition)[keyof typeof PopoverPosition];
|
24 | export { Boundary as PopperBoundary, Placement, placements as PopperPlacements };
|
25 | export type StrictModifierNames = NonNullable<StrictModifiers["name"]>;
|
26 | /**
|
27 | * Configuration object for customizing popper.js v2 modifiers in Popover and Tooltip.
|
28 | *
|
29 | * @see https://popper.js.org/docs/v2/modifiers/
|
30 | */
|
31 | export type PopperModifierOverrides = Partial<{
|
32 | [M in StrictModifierNames]: Partial<Omit<StrictModifier<M>, "name">>;
|
33 | }>;
|
34 | /**
|
35 | * Custom popper.js v2 modifier for Popover and Tooltip.
|
36 | *
|
37 | * @see https://popper.js.org/docs/v2/modifiers/#custom-modifiers
|
38 | */
|
39 | export type PopperCustomModifier = Partial<Modifier<any, object>>;
|
40 | /**
|
41 | * Default props interface for the Popover target element.
|
42 | *
|
43 | * These props are applied to the generated target element (whose tag name is customizable via `targetTagName`)
|
44 | * or, when the `renderTarget` API is used, sent as props to that render function.
|
45 | *
|
46 | * This interface is generic enough to be compatible with the various HTML attributes Popover needs in
|
47 | * order to function properly, including things like event handlers and ARIA accessibility attributes.
|
48 | */
|
49 | export type DefaultPopoverTargetHTMLProps = React.HTMLProps<HTMLElement>;
|
50 | /**
|
51 | * Properties injected by Popover when rendering custom targets via the `renderTarget` API.
|
52 | *
|
53 | * @see https://blueprintjs.com/docs/#core/components/popover.structure
|
54 | */
|
55 | export interface PopoverTargetProps extends Pick<React.HTMLAttributes<HTMLElement>, "aria-haspopup" | "className" | "tabIndex"> {
|
56 | /** Target ref. */
|
57 | ref: React.Ref<any>;
|
58 | /** Whether the popover or tooltip is currently open. */
|
59 | isOpen: boolean;
|
60 | }
|
61 | /**
|
62 | * Event handlers injected by Popover for hover interaction popovers.
|
63 | */
|
64 | export type PopoverHoverTargetHandlers<TProps extends DefaultPopoverTargetHTMLProps = DefaultPopoverTargetHTMLProps> = Pick<TProps, "onBlur" | "onContextMenu" | "onFocus" | "onMouseEnter" | "onMouseLeave">;
|
65 | /**
|
66 | * Event handlers injected by Popover for click interaction popovers.
|
67 | */
|
68 | export type PopoverClickTargetHandlers<TProps extends DefaultPopoverTargetHTMLProps = DefaultPopoverTargetHTMLProps> = Pick<TProps, "onClick" | "onKeyDown">;
|
69 | /**
|
70 | * Props shared between `Popover` and `Tooltip`.
|
71 | *
|
72 | * @template TProps HTML props interface for target element,
|
73 | * defaults to props for HTMLElement in IPopoverProps and ITooltipProps
|
74 | */
|
75 | export interface PopoverSharedProps<TProps extends DefaultPopoverTargetHTMLProps> extends OverlayableProps, Props {
|
76 | /** Interactive element which will trigger the popover. */
|
77 | children?: React.ReactNode;
|
78 | /**
|
79 | * A boundary element supplied to the "flip" and "preventOverflow" modifiers.
|
80 | * This is a shorthand for overriding Popper.js modifier options with the `modifiers` prop.
|
81 | *
|
82 | * @see https://popper.js.org/docs/v2/utils/detect-overflow/#boundary
|
83 | */
|
84 | boundary?: Boundary;
|
85 | /**
|
86 | * When enabled, clicks inside a `Classes.POPOVER_DISMISS` element
|
87 | * will only close the current popover and not outer popovers.
|
88 | * When disabled, the current popover and any ancestor popovers will be closed.
|
89 | *
|
90 | * @see http://blueprintjs.com/docs/#core/components/popover.closing-on-click
|
91 | * @default false
|
92 | */
|
93 | captureDismiss?: boolean;
|
94 | /**
|
95 | * Initial opened state when uncontrolled.
|
96 | *
|
97 | * @default false
|
98 | */
|
99 | defaultIsOpen?: boolean;
|
100 | /**
|
101 | * Prevents the popover from appearing when `true`.
|
102 | *
|
103 | * @default false
|
104 | */
|
105 | disabled?: boolean;
|
106 | /**
|
107 | * Whether the wrapper and target should take up the full width of their container.
|
108 | * Note that supplying `true` for this prop will force `targetTagName="div"`.
|
109 | */
|
110 | fill?: boolean;
|
111 | /**
|
112 | * The amount of time in milliseconds the popover should remain open after
|
113 | * the user hovers off the trigger. The timer is canceled if the user mouses
|
114 | * over the target before it expires.
|
115 | *
|
116 | * @default 300
|
117 | */
|
118 | hoverCloseDelay?: number;
|
119 | /**
|
120 | * The amount of time in milliseconds the popover should wait before opening
|
121 | * after the user hovers over the trigger. The timer is canceled if the user
|
122 | * mouses away from the target before it expires.
|
123 | *
|
124 | * @default 150
|
125 | */
|
126 | hoverOpenDelay?: number;
|
127 | /**
|
128 | * Whether a popover that uses a `Portal` should automatically inherit the
|
129 | * dark theme from its parent.
|
130 | *
|
131 | * @default true
|
132 | */
|
133 | inheritDarkTheme?: boolean;
|
134 | /**
|
135 | * Whether the popover is visible. Passing this prop puts the popover in
|
136 | * controlled mode, where the only way to change visibility is by updating
|
137 | * this property. If `disabled={true}`, this prop will be ignored, and the
|
138 | * popover will remain closed.
|
139 | *
|
140 | * @default undefined
|
141 | */
|
142 | isOpen?: boolean;
|
143 | /**
|
144 | * Whether the popover content should be sized to match the width of the target.
|
145 | * This is sometimes useful for dropdown menus. This prop is implemented using
|
146 | * a Popper.js custom modifier.
|
147 | *
|
148 | * @default false
|
149 | */
|
150 | matchTargetWidth?: boolean;
|
151 | /**
|
152 | * Whether to apply minimal styling to this popover or tooltip. Minimal popovers
|
153 | * do not have an arrow pointing to their target and use a subtler animation.
|
154 | *
|
155 | * @default false
|
156 | */
|
157 | minimal?: boolean;
|
158 | /**
|
159 | * Overrides for Popper.js built-in modifiers.
|
160 | * Each override is is a full modifier object (omitting its name), keyed by its modifier name.
|
161 | *
|
162 | * For example, the arrow modifier can be disabled by providing `{ arrow: { enabled: false } }`.
|
163 | *
|
164 | * Some of Popover's default modifiers may get disabled under certain circumstances, but you may
|
165 | * choose to re-enable and customize them. For example, "offset" is disabled when `minimal={true}`,
|
166 | * but you can re-enable it with `{ offset: { enabled: true } }`.
|
167 | *
|
168 | * @see https://popper.js.org/docs/v2/modifiers/
|
169 | */
|
170 | modifiers?: PopperModifierOverrides;
|
171 | /**
|
172 | * Custom modifiers to add to the popper instance.
|
173 | *
|
174 | * @see https://popper.js.org/docs/v2/modifiers/#custom-modifiers
|
175 | */
|
176 | modifiersCustom?: readonly PopperCustomModifier[];
|
177 | /**
|
178 | * Callback invoked in controlled mode when the popover open state *would*
|
179 | * change due to user interaction.
|
180 | */
|
181 | onInteraction?: (nextOpenState: boolean, e?: React.SyntheticEvent<HTMLElement>) => void;
|
182 | /**
|
183 | * Whether the popover should open when its target is focused. If `true`,
|
184 | * target will render with `tabindex="0"` to make it focusable via keyboard
|
185 | * navigation.
|
186 | *
|
187 | * Note that this functionality is only enabled for hover interaction
|
188 | * popovers/tooltips.
|
189 | *
|
190 | * @default true
|
191 | */
|
192 | openOnTargetFocus?: boolean;
|
193 | /**
|
194 | * Ref supplied to the `Classes.POPOVER` element.
|
195 | */
|
196 | popoverRef?: React.Ref<HTMLElement>;
|
197 | /**
|
198 | * Target renderer which receives props injected by Popover which should be spread onto
|
199 | * the rendered element. This function should return a single React node.
|
200 | *
|
201 | * Mutually exclusive with `children` and `targetTagName` props.
|
202 | */
|
203 | renderTarget?: (props: PopoverTargetProps & PopoverHoverTargetHandlers<TProps> & PopoverClickTargetHandlers<TProps>) => JSX.Element;
|
204 | /**
|
205 | * A root boundary element supplied to the "flip" and "preventOverflow" modifiers.
|
206 | * This is a shorthand for overriding Popper.js modifier options with the `modifiers` prop.
|
207 | *
|
208 | * @see https://popper.js.org/docs/v2/utils/detect-overflow/#rootboundary
|
209 | */
|
210 | rootBoundary?: RootBoundary;
|
211 | /**
|
212 | * The placement (relative to the target) at which the popover should appear.
|
213 | * Mutually exclusive with `position` prop. Prefer using this over `position`,
|
214 | * as it more closely aligns with Popper.js semantics.
|
215 | *
|
216 | * The default value of `"auto"` will choose the best placement when opened
|
217 | * and will allow the popover to reposition itself to remain onscreen as the
|
218 | * user scrolls around.
|
219 | *
|
220 | * @default "auto"
|
221 | */
|
222 | placement?: Placement;
|
223 | /**
|
224 | * A space-delimited string of class names applied to the popover element.
|
225 | */
|
226 | popoverClassName?: string;
|
227 | /**
|
228 | * The position (relative to the target) at which the popover should appear.
|
229 | * Mutually exclusive with `placement` prop.
|
230 | *
|
231 | * The default value of `"auto"` will choose the best position when opened
|
232 | * and will allow the popover to reposition itself to remain onscreen as the
|
233 | * user scrolls around.
|
234 | *
|
235 | * @default "auto"
|
236 | */
|
237 | position?: PopoverPosition;
|
238 | /**
|
239 | * HTML tag name for the target element. This must be an HTML element to
|
240 | * ensure that it supports the necessary DOM event handlers.
|
241 | *
|
242 | * By default, a `<span>` tag is used so popovers appear as inline-block
|
243 | * elements and can be nested in text. Use `<div>` tag for a block element.
|
244 | *
|
245 | * If `fill` is set to `true`, this prop's default value will become `"div"`
|
246 | * instead of `"span"`.
|
247 | *
|
248 | * Note that _not all HTML tags are supported_; you will need to make sure
|
249 | * the tag you choose supports the HTML attributes Popover applies to the
|
250 | * target element.
|
251 | *
|
252 | * This prop is mutually exclusive with the `renderTarget` API.
|
253 | *
|
254 | * @default "span" ("div" if `fill={true}`)
|
255 | */
|
256 | targetTagName?: keyof JSX.IntrinsicElements;
|
257 | /**
|
258 | * HTML props for the target element. This is useful in some cases where you
|
259 | * need to render some simple attributes on the generated target element.
|
260 | *
|
261 | * For more complex use cases, consider using the `renderTarget` API instead.
|
262 | * This prop will be ignored if `renderTarget` is used.
|
263 | */
|
264 | targetProps?: TProps;
|
265 | /**
|
266 | * Whether the popover should be rendered inside a `Portal` attached to
|
267 | * `portalContainer` prop.
|
268 | *
|
269 | * Rendering content inside a `Portal` allows the popover content to escape
|
270 | * the physical bounds of its parent while still being positioned correctly
|
271 | * relative to its target. Using a `Portal` is necessary if any ancestor of
|
272 | * the target hides overflow or uses very complex positioning.
|
273 | *
|
274 | * Not using a `Portal` can result in smoother performance when scrolling
|
275 | * and allows the popover content to inherit CSS styles from surrounding
|
276 | * elements, but it remains subject to the overflow bounds of its ancestors.
|
277 | *
|
278 | * @default true
|
279 | */
|
280 | usePortal?: boolean;
|
281 | }
|