@blueprintjs/core
Version:
Core styles & components
71 lines • 3.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tooltip = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
/*
* Copyright 2021 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const react_1 = require("react");
const common_1 = require("../../common");
const Classes = tslib_1.__importStar(require("../../common/classes"));
const popover_1 = require("../popover/popover");
const popoverArrow_1 = require("../popover/popoverArrow");
const tooltipContext_1 = require("../popover/tooltipContext");
/**
* Tooltip component.
*
* @see https://blueprintjs.com/docs/#core/components/tooltip
*/
class Tooltip extends common_1.AbstractPureComponent {
static displayName = `${common_1.DISPLAYNAME_PREFIX}.Tooltip`;
static defaultProps = {
compact: false,
hoverCloseDelay: 0,
hoverOpenDelay: 100,
interactionKind: "hover-target",
minimal: false,
transitionDuration: 100,
};
popoverRef = (0, react_1.createRef)();
render() {
// if we have an ancestor TooltipContext, we should take its state into account in this render path,
// it was likely created by a parent ContextMenu
return ((0, jsx_runtime_1.jsx)(tooltipContext_1.TooltipContext.Consumer, { children: ([state]) => (0, jsx_runtime_1.jsx)(tooltipContext_1.TooltipProvider, { ...state, children: this.renderPopover }) }));
}
reposition() {
this.popoverRef.current?.reposition();
}
// any descendant ContextMenus may update this ctxState
renderPopover = (ctxState) => {
const { children, compact, disabled, intent, popoverClassName, ...restProps } = this.props;
const popoverClasses = (0, classnames_1.default)(Classes.TOOLTIP, Classes.intentClass(intent), popoverClassName, {
[Classes.COMPACT]: compact,
});
return ((0, jsx_runtime_1.jsx)(popover_1.Popover, { modifiers: {
arrow: {
enabled: !this.props.minimal,
},
offset: {
options: {
offset: [0, popoverArrow_1.TOOLTIP_ARROW_SVG_SIZE / 2],
},
},
}, ...restProps, autoFocus: false, canEscapeKeyClose: false, disabled: ctxState.forceDisabled ?? disabled, enforceFocus: false, lazy: true, popoverClassName: popoverClasses, portalContainer: this.props.portalContainer, ref: this.popoverRef, children: children }));
};
}
exports.Tooltip = Tooltip;
//# sourceMappingURL=tooltip.js.map