1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __extends } from "tslib";
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 | import { Manager, Popper, Reference } from "react-popper";
|
20 | import { AbstractPureComponent, Classes, DISPLAYNAME_PREFIX, refHandler, Utils } from "../../common";
|
21 | import * as Errors from "../../common/errors";
|
22 | import { Overlay } from "../overlay/overlay";
|
23 | import { ResizeSensor } from "../resize-sensor/resizeSensor";
|
24 |
|
25 | import { Tooltip } from "../tooltip/tooltip";
|
26 | import { matchReferenceWidthModifier } from "./customModifiers";
|
27 | import { POPOVER_ARROW_SVG_SIZE, PopoverArrow } from "./popoverArrow";
|
28 | import { positionToPlacement } from "./popoverPlacementUtils";
|
29 | import { getBasePlacement, getTransformOrigin } from "./popperUtils";
|
30 | export var PopoverInteractionKind = {
|
31 | CLICK: "click",
|
32 | CLICK_TARGET_ONLY: "click-target",
|
33 | HOVER: "hover",
|
34 | HOVER_TARGET_ONLY: "hover-target",
|
35 | };
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | var Popover = (function (_super) {
|
45 | __extends(Popover, _super);
|
46 | function Popover() {
|
47 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
48 | _this.state = {
|
49 | hasDarkParent: false,
|
50 | isOpen: _this.getIsOpen(_this.props),
|
51 | };
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | _this.popoverElement = null;
|
60 |
|
61 | _this.popoverRef = refHandler(_this, "popoverElement", _this.props.popoverRef);
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 | _this.targetRef = React.createRef();
|
68 |
|
69 |
|
70 | _this.isMouseInTargetOrPopover = false;
|
71 |
|
72 |
|
73 | _this.lostFocusOnSamePage = true;
|
74 | _this.isControlled = function () { return _this.props.isOpen !== undefined; };
|
75 |
|
76 | _this.isArrowEnabled = function () { var _a, _b; return !_this.props.minimal && ((_b = (_a = _this.props.modifiers) === null || _a === void 0 ? void 0 : _a.arrow) === null || _b === void 0 ? void 0 : _b.enabled) !== false; };
|
77 | _this.isHoverInteractionKind = function () {
|
78 | return (_this.props.interactionKind === PopoverInteractionKind.HOVER ||
|
79 | _this.props.interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY);
|
80 | };
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | _this.reposition = function () { var _a; return (_a = _this.popperScheduleUpdate) === null || _a === void 0 ? void 0 : _a.call(_this); };
|
90 | _this.renderTarget = function (_a) {
|
91 | var _b, _c;
|
92 | var _d, _e;
|
93 | var ref = _a.ref;
|
94 | var _f = _this.props, children = _f.children, className = _f.className, fill = _f.fill, openOnTargetFocus = _f.openOnTargetFocus, renderTarget = _f.renderTarget;
|
95 | var isOpen = _this.state.isOpen;
|
96 | var isControlled = _this.isControlled();
|
97 | var isHoverInteractionKind = _this.isHoverInteractionKind();
|
98 | var targetTagName = _this.props.targetTagName;
|
99 | if (fill) {
|
100 | targetTagName = "div";
|
101 | }
|
102 | var targetEventHandlers = isHoverInteractionKind
|
103 | ? {
|
104 |
|
105 | onBlur: _this.handleTargetBlur,
|
106 | onContextMenu: _this.handleTargetContextMenu,
|
107 | onFocus: _this.handleTargetFocus,
|
108 | onMouseEnter: _this.handleMouseEnter,
|
109 | onMouseLeave: _this.handleMouseLeave,
|
110 | }
|
111 | : {
|
112 |
|
113 | onClick: _this.handleTargetClick,
|
114 |
|
115 | onKeyDown: _this.handleKeyDown,
|
116 | };
|
117 |
|
118 | var targetTabIndex = openOnTargetFocus && isHoverInteractionKind ? 0 : undefined;
|
119 | var ownTargetProps = __assign({ "aria-haspopup": (_d = _this.props.popupKind) !== null && _d !== void 0 ? _d : (_this.props.interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY
|
120 | ? undefined
|
121 | : "true"),
|
122 |
|
123 |
|
124 |
|
125 | className: classNames(className, Classes.POPOVER_TARGET, (_b = {},
|
126 | _b[Classes.POPOVER_OPEN] = isOpen,
|
127 |
|
128 | _b[Classes.ACTIVE] = isOpen && !isControlled && !isHoverInteractionKind,
|
129 | _b)), ref: ref }, targetEventHandlers);
|
130 | var targetModifierClasses = (_c = {},
|
131 |
|
132 |
|
133 | _c[Classes.ACTIVE] = isOpen && !isControlled && !isHoverInteractionKind,
|
134 |
|
135 | _c[Classes.FILL] = fill,
|
136 | _c);
|
137 | var target;
|
138 | if (renderTarget !== undefined) {
|
139 | target = renderTarget(__assign(__assign({}, ownTargetProps), { className: classNames(ownTargetProps.className, targetModifierClasses),
|
140 |
|
141 |
|
142 | isOpen: isOpen, tabIndex: targetTabIndex }));
|
143 | }
|
144 | else {
|
145 | var childTarget = Utils.ensureElement(React.Children.toArray(children)[0]);
|
146 | if (childTarget === undefined) {
|
147 | return null;
|
148 | }
|
149 | var clonedTarget = React.cloneElement(childTarget, {
|
150 | className: classNames(childTarget.props.className, targetModifierClasses),
|
151 |
|
152 | disabled: isOpen && Utils.isElementOfType(childTarget, Tooltip) ? true : childTarget.props.disabled,
|
153 | tabIndex: (_e = childTarget.props.tabIndex) !== null && _e !== void 0 ? _e : targetTabIndex,
|
154 | });
|
155 | var wrappedTarget = React.createElement(targetTagName, __assign(__assign({}, ownTargetProps), _this.props.targetProps), clonedTarget);
|
156 | target = wrappedTarget;
|
157 | }
|
158 |
|
159 |
|
160 | return (React.createElement(ResizeSensor, { targetRef: _this.targetRef, onResize: _this.reposition }, target));
|
161 | };
|
162 | _this.renderPopover = function (popperProps) {
|
163 | var _a;
|
164 | var _b;
|
165 | var _c = _this.props, interactionKind = _c.interactionKind, shouldReturnFocusOnClose = _c.shouldReturnFocusOnClose, usePortal = _c.usePortal;
|
166 | var isOpen = _this.state.isOpen;
|
167 |
|
168 | var transformOrigin = getTransformOrigin(popperProps.placement, _this.isArrowEnabled() ? popperProps.arrowProps.style : undefined);
|
169 |
|
170 | _this.popperScheduleUpdate = popperProps.update;
|
171 | var popoverHandlers = {
|
172 |
|
173 | onClick: _this.handlePopoverClick,
|
174 |
|
175 | onKeyDown: function (event) { return Utils.isKeyboardClick(event) && _this.handlePopoverClick(event); },
|
176 | };
|
177 | if (interactionKind === PopoverInteractionKind.HOVER ||
|
178 | (!usePortal && interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY)) {
|
179 | popoverHandlers.onMouseEnter = _this.handleMouseEnter;
|
180 | popoverHandlers.onMouseLeave = _this.handleMouseLeave;
|
181 | }
|
182 | var basePlacement = getBasePlacement(popperProps.placement);
|
183 | var popoverClasses = classNames(Classes.POPOVER, (_a = {},
|
184 | _a[Classes.DARK] = _this.props.inheritDarkTheme && _this.state.hasDarkParent,
|
185 | _a[Classes.MINIMAL] = _this.props.minimal,
|
186 | _a[Classes.POPOVER_CAPTURING_DISMISS] = _this.props.captureDismiss,
|
187 | _a[Classes.POPOVER_MATCH_TARGET_WIDTH] = _this.props.matchTargetWidth,
|
188 | _a[Classes.POPOVER_REFERENCE_HIDDEN] = popperProps.isReferenceHidden === true,
|
189 | _a[Classes.POPOVER_POPPER_ESCAPED] = popperProps.hasPopperEscaped === true,
|
190 | _a), "".concat(Classes.POPOVER_CONTENT_PLACEMENT, "-").concat(basePlacement), _this.props.popoverClassName);
|
191 | var defaultAutoFocus = _this.isHoverInteractionKind() ? false : undefined;
|
192 | return (React.createElement(Overlay, { autoFocus: (_b = _this.props.autoFocus) !== null && _b !== void 0 ? _b : defaultAutoFocus, backdropClassName: Classes.POPOVER_BACKDROP, backdropProps: _this.props.backdropProps, canEscapeKeyClose: _this.props.canEscapeKeyClose, canOutsideClickClose: _this.props.interactionKind === PopoverInteractionKind.CLICK, enforceFocus: _this.props.enforceFocus, hasBackdrop: _this.props.hasBackdrop, isOpen: isOpen, onClose: _this.handleOverlayClose, onClosed: _this.props.onClosed, onClosing: _this.props.onClosing, onOpened: _this.props.onOpened, onOpening: _this.props.onOpening, transitionDuration: _this.props.transitionDuration, transitionName: Classes.POPOVER, usePortal: _this.props.usePortal, portalClassName: _this.props.portalClassName, portalContainer: _this.props.portalContainer, portalStopPropagationEvents: _this.props.portalStopPropagationEvents,
|
193 |
|
194 | shouldReturnFocusOnClose: _this.isHoverInteractionKind() ? false : shouldReturnFocusOnClose },
|
195 | React.createElement("div", { className: Classes.POPOVER_TRANSITION_CONTAINER, ref: popperProps.ref, style: popperProps.style },
|
196 | React.createElement(ResizeSensor, { onResize: _this.reposition },
|
197 | React.createElement("div", __assign({ className: popoverClasses, style: { transformOrigin: transformOrigin }, ref: _this.popoverRef }, popoverHandlers),
|
198 | _this.isArrowEnabled() && (React.createElement(PopoverArrow, { arrowProps: popperProps.arrowProps, placement: popperProps.placement })),
|
199 | React.createElement("div", { className: Classes.POPOVER_CONTENT }, _this.props.content))))));
|
200 | };
|
201 | _this.handleTargetFocus = function (e) {
|
202 | if (_this.props.openOnTargetFocus && _this.isHoverInteractionKind()) {
|
203 | if (e.relatedTarget == null && !_this.lostFocusOnSamePage) {
|
204 |
|
205 |
|
206 | return;
|
207 | }
|
208 | _this.handleMouseEnter(e);
|
209 | }
|
210 | };
|
211 | _this.handleTargetBlur = function (e) {
|
212 | if (_this.props.openOnTargetFocus && _this.isHoverInteractionKind()) {
|
213 | if (e.relatedTarget != null) {
|
214 |
|
215 |
|
216 | if (e.relatedTarget !== _this.popoverElement &&
|
217 | !_this.isElementInPopover(e.relatedTarget)) {
|
218 | _this.handleMouseLeave(e);
|
219 | }
|
220 | }
|
221 | else {
|
222 | _this.handleMouseLeave(e);
|
223 | }
|
224 | }
|
225 | _this.lostFocusOnSamePage = e.relatedTarget != null;
|
226 | };
|
227 | _this.handleTargetContextMenu = function (e) {
|
228 |
|
229 |
|
230 | if (e.defaultPrevented) {
|
231 | _this.setOpenState(false, e);
|
232 | }
|
233 | };
|
234 | _this.handleMouseEnter = function (e) {
|
235 | _this.isMouseInTargetOrPopover = true;
|
236 |
|
237 |
|
238 | if (!_this.props.usePortal &&
|
239 | _this.isElementInPopover(e.target) &&
|
240 | _this.props.interactionKind === PopoverInteractionKind.HOVER_TARGET_ONLY &&
|
241 | !_this.props.openOnTargetFocus) {
|
242 | _this.handleMouseLeave(e);
|
243 | }
|
244 | else if (!_this.props.disabled) {
|
245 |
|
246 | _this.setOpenState(true, e, _this.props.hoverOpenDelay);
|
247 | }
|
248 | };
|
249 | _this.handleMouseLeave = function (e) {
|
250 | _this.isMouseInTargetOrPopover = false;
|
251 |
|
252 |
|
253 |
|
254 | _this.setTimeout(function () {
|
255 | if (_this.isMouseInTargetOrPopover) {
|
256 | return;
|
257 | }
|
258 |
|
259 | _this.setOpenState(false, e, _this.props.hoverCloseDelay);
|
260 | });
|
261 | };
|
262 | _this.handlePopoverClick = function (e) {
|
263 | var _a, _b, _c, _d;
|
264 | var eventTarget = e.target;
|
265 | var eventPopover = eventTarget.closest(".".concat(Classes.POPOVER));
|
266 | var eventPopoverV1 = eventTarget.closest(".".concat(Classes.POPOVER));
|
267 | var isEventFromSelf = (eventPopover !== null && eventPopover !== void 0 ? eventPopover : eventPopoverV1) === _this.getPopoverElement();
|
268 | var isEventPopoverCapturing = (_b = (_a = eventPopover === null || eventPopover === void 0 ? void 0 : eventPopover.classList.contains(Classes.POPOVER_CAPTURING_DISMISS)) !== null && _a !== void 0 ? _a : eventPopoverV1 === null || eventPopoverV1 === void 0 ? void 0 : eventPopoverV1.classList.contains(Classes.POPOVER_CAPTURING_DISMISS)) !== null && _b !== void 0 ? _b : false;
|
269 |
|
270 | var dismissElement = eventTarget.closest(".".concat(Classes.POPOVER_DISMISS, ", .").concat(Classes.POPOVER_DISMISS_OVERRIDE));
|
271 |
|
272 |
|
273 |
|
274 | var dismissElementV1 = eventTarget.closest(".".concat(Classes.POPOVER_DISMISS, ", .").concat(Classes.POPOVER_DISMISS_OVERRIDE));
|
275 | var shouldDismiss = (_d = (_c = dismissElement === null || dismissElement === void 0 ? void 0 : dismissElement.classList.contains(Classes.POPOVER_DISMISS)) !== null && _c !== void 0 ? _c : dismissElementV1 === null || dismissElementV1 === void 0 ? void 0 : dismissElementV1.classList.contains(Classes.POPOVER_DISMISS)) !== null && _d !== void 0 ? _d : false;
|
276 | var isDisabled = eventTarget.closest(":disabled, .".concat(Classes.DISABLED)) != null;
|
277 | if (shouldDismiss && !isDisabled && (!isEventPopoverCapturing || isEventFromSelf)) {
|
278 | _this.setOpenState(false, e);
|
279 | }
|
280 | };
|
281 | _this.handleOverlayClose = function (e) {
|
282 | var _a;
|
283 | if (_this.targetRef.current == null || e === undefined) {
|
284 | return;
|
285 | }
|
286 | var event = ((_a = e.nativeEvent) !== null && _a !== void 0 ? _a : e);
|
287 | var eventTarget = (event.composed ? event.composedPath()[0] : event.target);
|
288 |
|
289 | if (!Utils.elementIsOrContains(_this.targetRef.current, eventTarget) || e.nativeEvent instanceof KeyboardEvent) {
|
290 | _this.setOpenState(false, e);
|
291 | }
|
292 | };
|
293 | _this.handleKeyDown = function (e) {
|
294 | var isKeyboardClick = Utils.isKeyboardClick(e);
|
295 |
|
296 | if (isKeyboardClick) {
|
297 | _this.handleTargetClick(e);
|
298 | }
|
299 | };
|
300 | _this.handleTargetClick = function (e) {
|
301 |
|
302 |
|
303 | var shouldIgnoreClick = _this.state.isOpen && _this.isSimulatedButtonClick(e);
|
304 | if (!shouldIgnoreClick) {
|
305 |
|
306 | if (!_this.props.disabled && !_this.isElementInPopover(e.target)) {
|
307 | if (_this.props.isOpen == null) {
|
308 | _this.setState(function (prevState) { return ({ isOpen: !prevState.isOpen }); });
|
309 | }
|
310 | else {
|
311 | _this.setOpenState(!_this.props.isOpen, e);
|
312 | }
|
313 | }
|
314 | }
|
315 | };
|
316 | _this.isSimulatedButtonClick = function (e) {
|
317 | return !e.isTrusted && e.target.matches(".".concat(Classes.BUTTON));
|
318 | };
|
319 | return _this;
|
320 | }
|
321 |
|
322 |
|
323 | Popover.prototype.getPopoverElement = function () {
|
324 | var _a;
|
325 | return (_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(Classes.POPOVER));
|
326 | };
|
327 | Popover.prototype.getIsOpen = function (props) {
|
328 | var _a;
|
329 |
|
330 | if (props.disabled) {
|
331 | return false;
|
332 | }
|
333 | else {
|
334 | return (_a = props.isOpen) !== null && _a !== void 0 ? _a : props.defaultIsOpen;
|
335 | }
|
336 | };
|
337 | Popover.prototype.render = function () {
|
338 | var _a = this.props, disabled = _a.disabled, content = _a.content, placement = _a.placement, _b = _a.position, position = _b === void 0 ? "auto" : _b, positioningStrategy = _a.positioningStrategy;
|
339 | var isOpen = this.state.isOpen;
|
340 | var isContentEmpty = content == null || (typeof content === "string" && content.trim() === "");
|
341 | if (isContentEmpty) {
|
342 |
|
343 |
|
344 | if (!disabled && isOpen !== false && !Utils.isNodeEnv("production")) {
|
345 | console.warn(Errors.POPOVER_WARN_EMPTY_CONTENT);
|
346 | }
|
347 |
|
348 | return this.renderTarget({ ref: noop });
|
349 | }
|
350 | return (React.createElement(Manager, null,
|
351 | React.createElement(Reference, { innerRef: this.targetRef }, this.renderTarget),
|
352 | React.createElement(Popper, { innerRef: this.popoverRef, placement: placement !== null && placement !== void 0 ? placement : positionToPlacement(position), strategy: positioningStrategy, modifiers: this.getPopperModifiers() }, this.renderPopover)));
|
353 | };
|
354 | Popover.prototype.componentDidMount = function () {
|
355 | this.updateDarkParent();
|
356 | };
|
357 | Popover.prototype.componentDidUpdate = function (props, state) {
|
358 | _super.prototype.componentDidUpdate.call(this, props, state);
|
359 | this.updateDarkParent();
|
360 | var nextIsOpen = this.getIsOpen(this.props);
|
361 | if (this.props.isOpen != null && nextIsOpen !== this.state.isOpen) {
|
362 | this.setOpenState(nextIsOpen);
|
363 |
|
364 |
|
365 | this.setState({ isOpen: nextIsOpen });
|
366 | }
|
367 | else if (this.props.disabled && this.state.isOpen && this.props.isOpen == null) {
|
368 |
|
369 | this.setOpenState(false);
|
370 | }
|
371 | };
|
372 | Popover.prototype.validateProps = function (props) {
|
373 | if (props.isOpen == null && props.onInteraction != null) {
|
374 | console.warn(Errors.POPOVER_WARN_UNCONTROLLED_ONINTERACTION);
|
375 | }
|
376 | if (props.hasBackdrop && !props.usePortal) {
|
377 | console.warn(Errors.POPOVER_WARN_HAS_BACKDROP_INLINE);
|
378 | }
|
379 | if (props.hasBackdrop && props.interactionKind !== PopoverInteractionKind.CLICK) {
|
380 | console.warn(Errors.POPOVER_HAS_BACKDROP_INTERACTION);
|
381 | }
|
382 | if (props.placement !== undefined && props.position !== undefined) {
|
383 | console.warn(Errors.POPOVER_WARN_PLACEMENT_AND_POSITION_MUTEX);
|
384 | }
|
385 | var childrenCount = React.Children.count(props.children);
|
386 | var hasRenderTargetProp = props.renderTarget !== undefined;
|
387 | var hasTargetPropsProp = props.targetProps !== undefined;
|
388 | if (childrenCount === 0 && !hasRenderTargetProp) {
|
389 | console.warn(Errors.POPOVER_REQUIRES_TARGET);
|
390 | }
|
391 | if (childrenCount > 1) {
|
392 | console.warn(Errors.POPOVER_WARN_TOO_MANY_CHILDREN);
|
393 | }
|
394 | if (childrenCount > 0 && hasRenderTargetProp) {
|
395 | console.warn(Errors.POPOVER_WARN_DOUBLE_TARGET);
|
396 | }
|
397 | if (hasRenderTargetProp && hasTargetPropsProp) {
|
398 | console.warn(Errors.POPOVER_WARN_TARGET_PROPS_WITH_RENDER_TARGET);
|
399 | }
|
400 | };
|
401 | Popover.prototype.getPopperModifiers = function () {
|
402 | var _a, _b, _c, _d;
|
403 | var _e = this.props, matchTargetWidth = _e.matchTargetWidth, modifiers = _e.modifiers, modifiersCustom = _e.modifiersCustom;
|
404 | var popperModifiers = [
|
405 | __assign({ enabled: this.isArrowEnabled(), name: "arrow" }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.arrow),
|
406 | __assign(__assign({ name: "computeStyles" }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.computeStyles), { options: __assign({ adaptive: true,
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 | gpuAcceleration: false }, (_a = modifiers === null || modifiers === void 0 ? void 0 : modifiers.computeStyles) === null || _a === void 0 ? void 0 : _a.options) }),
|
413 | __assign(__assign({ enabled: this.isArrowEnabled(), name: "offset" }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.offset), { options: __assign({ offset: [0, POPOVER_ARROW_SVG_SIZE / 2] }, (_b = modifiers === null || modifiers === void 0 ? void 0 : modifiers.offset) === null || _b === void 0 ? void 0 : _b.options) }),
|
414 | __assign(__assign({ name: "flip" }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.flip), { options: __assign({ boundary: this.props.boundary, rootBoundary: this.props.rootBoundary }, (_c = modifiers === null || modifiers === void 0 ? void 0 : modifiers.flip) === null || _c === void 0 ? void 0 : _c.options) }),
|
415 | __assign(__assign({ name: "preventOverflow" }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.preventOverflow), { options: __assign({ boundary: this.props.boundary, rootBoundary: this.props.rootBoundary }, (_d = modifiers === null || modifiers === void 0 ? void 0 : modifiers.preventOverflow) === null || _d === void 0 ? void 0 : _d.options) }),
|
416 | ];
|
417 | if (matchTargetWidth) {
|
418 | popperModifiers.push(matchReferenceWidthModifier);
|
419 | }
|
420 | if (modifiersCustom !== undefined) {
|
421 | popperModifiers.push.apply(popperModifiers, modifiersCustom);
|
422 | }
|
423 | return popperModifiers;
|
424 | };
|
425 |
|
426 |
|
427 | Popover.prototype.setOpenState = function (isOpen, e, timeout) {
|
428 | var _this = this;
|
429 | var _a, _b, _c, _d, _e;
|
430 |
|
431 | (_a = this.cancelOpenTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
|
432 | if (timeout !== undefined && timeout > 0) {
|
433 | this.cancelOpenTimeout = this.setTimeout(function () { return _this.setOpenState(isOpen, e); }, timeout);
|
434 | }
|
435 | else {
|
436 | if (this.props.isOpen == null) {
|
437 | this.setState({ isOpen: isOpen });
|
438 | }
|
439 | else {
|
440 | (_c = (_b = this.props).onInteraction) === null || _c === void 0 ? void 0 : _c.call(_b, isOpen, e);
|
441 | }
|
442 | if (!isOpen) {
|
443 |
|
444 |
|
445 | (_e = (_d = this.props).onClose) === null || _e === void 0 ? void 0 : _e.call(_d, e);
|
446 | }
|
447 | }
|
448 | };
|
449 | Popover.prototype.updateDarkParent = function () {
|
450 | if (this.props.usePortal && this.state.isOpen) {
|
451 | var hasDarkParent = this.targetRef.current != null && this.targetRef.current.closest(".".concat(Classes.DARK)) != null;
|
452 | this.setState({ hasDarkParent: hasDarkParent });
|
453 | }
|
454 | };
|
455 | Popover.prototype.isElementInPopover = function (element) {
|
456 | var _a, _b;
|
457 | return (_b = (_a = this.getPopoverElement()) === null || _a === void 0 ? void 0 : _a.contains(element)) !== null && _b !== void 0 ? _b : false;
|
458 | };
|
459 | Popover.displayName = "".concat(DISPLAYNAME_PREFIX, ".Popover");
|
460 | Popover.defaultProps = {
|
461 | boundary: "clippingParents",
|
462 | captureDismiss: false,
|
463 | defaultIsOpen: false,
|
464 | disabled: false,
|
465 | fill: false,
|
466 | hasBackdrop: false,
|
467 | hoverCloseDelay: 300,
|
468 | hoverOpenDelay: 150,
|
469 | inheritDarkTheme: true,
|
470 | interactionKind: PopoverInteractionKind.CLICK,
|
471 | matchTargetWidth: false,
|
472 | minimal: false,
|
473 | openOnTargetFocus: true,
|
474 |
|
475 |
|
476 | positioningStrategy: "absolute",
|
477 | renderTarget: undefined,
|
478 | shouldReturnFocusOnClose: false,
|
479 | targetTagName: "span",
|
480 | transitionDuration: 300,
|
481 | usePortal: true,
|
482 | };
|
483 | return Popover;
|
484 | }(AbstractPureComponent));
|
485 | export { Popover };
|
486 | function noop() {
|
487 |
|
488 | }
|
489 |
|
\ | No newline at end of file |