84 lines
3.2 KiB
JavaScript
84 lines
3.2 KiB
JavaScript
|
"use strict";
|
||
|
"use client";
|
||
|
|
||
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = void 0;
|
||
|
var _classnames = _interopRequireDefault(require("classnames"));
|
||
|
var React = _interopRequireWildcard(require("react"));
|
||
|
var _getRenderPropValue = require("../_util/getRenderPropValue");
|
||
|
var _motion = require("../_util/motion");
|
||
|
var _configProvider = require("../config-provider");
|
||
|
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
||
|
var _PurePanel = _interopRequireDefault(require("./PurePanel"));
|
||
|
var _style = _interopRequireDefault(require("./style"));
|
||
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
||
|
var t = {};
|
||
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
||
|
}
|
||
|
return t;
|
||
|
};
|
||
|
|
||
|
// CSSINJS
|
||
|
|
||
|
const Overlay = _ref => {
|
||
|
let {
|
||
|
title,
|
||
|
content,
|
||
|
prefixCls
|
||
|
} = _ref;
|
||
|
return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement("div", {
|
||
|
className: `${prefixCls}-title`
|
||
|
}, (0, _getRenderPropValue.getRenderPropValue)(title)), /*#__PURE__*/React.createElement("div", {
|
||
|
className: `${prefixCls}-inner-content`
|
||
|
}, (0, _getRenderPropValue.getRenderPropValue)(content)));
|
||
|
};
|
||
|
const Popover = /*#__PURE__*/React.forwardRef((props, ref) => {
|
||
|
const {
|
||
|
prefixCls: customizePrefixCls,
|
||
|
title,
|
||
|
content,
|
||
|
overlayClassName,
|
||
|
placement = 'top',
|
||
|
trigger = 'hover',
|
||
|
mouseEnterDelay = 0.1,
|
||
|
mouseLeaveDelay = 0.1,
|
||
|
overlayStyle = {}
|
||
|
} = props,
|
||
|
otherProps = __rest(props, ["prefixCls", "title", "content", "overlayClassName", "placement", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle"]);
|
||
|
const {
|
||
|
getPrefixCls
|
||
|
} = React.useContext(_configProvider.ConfigContext);
|
||
|
const prefixCls = getPrefixCls('popover', customizePrefixCls);
|
||
|
const [wrapSSR, hashId] = (0, _style.default)(prefixCls);
|
||
|
const rootPrefixCls = getPrefixCls();
|
||
|
const overlayCls = (0, _classnames.default)(overlayClassName, hashId);
|
||
|
return wrapSSR( /*#__PURE__*/React.createElement(_tooltip.default, Object.assign({
|
||
|
placement: placement,
|
||
|
trigger: trigger,
|
||
|
mouseEnterDelay: mouseEnterDelay,
|
||
|
mouseLeaveDelay: mouseLeaveDelay,
|
||
|
overlayStyle: overlayStyle
|
||
|
}, otherProps, {
|
||
|
prefixCls: prefixCls,
|
||
|
overlayClassName: overlayCls,
|
||
|
ref: ref,
|
||
|
overlay: title || content ? /*#__PURE__*/React.createElement(Overlay, {
|
||
|
prefixCls: prefixCls,
|
||
|
title: title,
|
||
|
content: content
|
||
|
}) : null,
|
||
|
transitionName: (0, _motion.getTransitionName)(rootPrefixCls, 'zoom-big', otherProps.transitionName),
|
||
|
"data-popover-inject": true
|
||
|
})));
|
||
|
});
|
||
|
if (process.env.NODE_ENV !== 'production') {
|
||
|
Popover.displayName = 'Popover';
|
||
|
}
|
||
|
Popover._InternalPanelDoNotUseOrYouWillBeFired = _PurePanel.default;
|
||
|
var _default = exports.default = Popover;
|