81 lines
3.6 KiB
JavaScript
81 lines
3.6 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
var _excluded = ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "afterVisibleChange", "transitionName", "animation", "motion", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer", "overlayInnerStyle", "arrowContent", "overlay", "id", "showArrow"];
|
|
import Trigger from '@rc-component/trigger';
|
|
import * as React from 'react';
|
|
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
import { placements } from "./placements";
|
|
import Popup from "./Popup";
|
|
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 = _objectWithoutProperties(props, _excluded);
|
|
var triggerRef = useRef(null);
|
|
useImperativeHandle(ref, function () {
|
|
return triggerRef.current;
|
|
});
|
|
var extraProps = _objectSpread({}, restProps);
|
|
if ('visible' in props) {
|
|
extraProps.popupVisible = props.visible;
|
|
}
|
|
var getPopupElement = function getPopupElement() {
|
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
key: "content",
|
|
prefixCls: prefixCls,
|
|
id: id,
|
|
overlayInnerStyle: overlayInnerStyle
|
|
}, overlay);
|
|
};
|
|
return /*#__PURE__*/React.createElement(Trigger, _extends({
|
|
popupClassName: overlayClassName,
|
|
prefixCls: prefixCls,
|
|
popup: getPopupElement,
|
|
action: trigger,
|
|
builtinPlacements: 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);
|
|
};
|
|
export default /*#__PURE__*/forwardRef(Tooltip); |