91 lines
5.2 KiB
JavaScript
91 lines
5.2 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
var _trigger = _interopRequireDefault(require("@rc-component/trigger"));
|
|
var React = _interopRequireWildcard(require("react"));
|
|
var _placements = require("./placements");
|
|
var _Popup = _interopRequireDefault(require("./Popup"));
|
|
var _excluded = ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "afterVisibleChange", "transitionName", "animation", "motion", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer", "overlayInnerStyle", "arrowContent", "overlay", "id", "showArrow"];
|
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
var Tooltip = function Tooltip(props, ref) {
|
|
var overlayClassName = props.overlayClassName,
|
|
_props$trigger = props.trigger,
|
|
trigger = _props$trigger === void 0 ? ['hover'] : _props$trigger,
|
|
_props$mouseEnterDela = props.mouseEnterDelay,
|
|
mouseEnterDelay = _props$mouseEnterDela === void 0 ? 0 : _props$mouseEnterDela,
|
|
_props$mouseLeaveDela = props.mouseLeaveDelay,
|
|
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela,
|
|
overlayStyle = props.overlayStyle,
|
|
_props$prefixCls = props.prefixCls,
|
|
prefixCls = _props$prefixCls === void 0 ? 'rc-tooltip' : _props$prefixCls,
|
|
children = props.children,
|
|
onVisibleChange = props.onVisibleChange,
|
|
afterVisibleChange = props.afterVisibleChange,
|
|
transitionName = props.transitionName,
|
|
animation = props.animation,
|
|
motion = props.motion,
|
|
_props$placement = props.placement,
|
|
placement = _props$placement === void 0 ? 'right' : _props$placement,
|
|
_props$align = props.align,
|
|
align = _props$align === void 0 ? {} : _props$align,
|
|
_props$destroyTooltip = props.destroyTooltipOnHide,
|
|
destroyTooltipOnHide = _props$destroyTooltip === void 0 ? false : _props$destroyTooltip,
|
|
defaultVisible = props.defaultVisible,
|
|
getTooltipContainer = props.getTooltipContainer,
|
|
overlayInnerStyle = props.overlayInnerStyle,
|
|
arrowContent = props.arrowContent,
|
|
overlay = props.overlay,
|
|
id = props.id,
|
|
_props$showArrow = props.showArrow,
|
|
showArrow = _props$showArrow === void 0 ? true : _props$showArrow,
|
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
var triggerRef = (0, React.useRef)(null);
|
|
(0, React.useImperativeHandle)(ref, function () {
|
|
return triggerRef.current;
|
|
});
|
|
var extraProps = (0, _objectSpread2.default)({}, restProps);
|
|
if ('visible' in props) {
|
|
extraProps.popupVisible = props.visible;
|
|
}
|
|
var getPopupElement = function getPopupElement() {
|
|
return /*#__PURE__*/React.createElement(_Popup.default, {
|
|
key: "content",
|
|
prefixCls: prefixCls,
|
|
id: id,
|
|
overlayInnerStyle: overlayInnerStyle
|
|
}, overlay);
|
|
};
|
|
return /*#__PURE__*/React.createElement(_trigger.default, (0, _extends2.default)({
|
|
popupClassName: overlayClassName,
|
|
prefixCls: prefixCls,
|
|
popup: getPopupElement,
|
|
action: trigger,
|
|
builtinPlacements: _placements.placements,
|
|
popupPlacement: placement,
|
|
ref: triggerRef,
|
|
popupAlign: align,
|
|
getPopupContainer: getTooltipContainer,
|
|
onPopupVisibleChange: onVisibleChange,
|
|
afterPopupVisibleChange: afterVisibleChange,
|
|
popupTransitionName: transitionName,
|
|
popupAnimation: animation,
|
|
popupMotion: motion,
|
|
defaultPopupVisible: defaultVisible,
|
|
autoDestroy: destroyTooltipOnHide,
|
|
mouseLeaveDelay: mouseLeaveDelay,
|
|
popupStyle: overlayStyle,
|
|
mouseEnterDelay: mouseEnterDelay,
|
|
arrow: showArrow
|
|
}, extraProps), children);
|
|
};
|
|
var _default = /*#__PURE__*/(0, React.forwardRef)(Tooltip);
|
|
exports.default = _default; |