86 lines
3.1 KiB
JavaScript
86 lines
3.1 KiB
JavaScript
|
"use strict";
|
||
|
"use client";
|
||
|
|
||
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = exports.RawPurePanel = exports.Overlay = void 0;
|
||
|
var React = _interopRequireWildcard(require("react"));
|
||
|
var _classnames = _interopRequireDefault(require("classnames"));
|
||
|
var _rcTooltip = require("rc-tooltip");
|
||
|
var _getRenderPropValue = require("../_util/getRenderPropValue");
|
||
|
var _configProvider = require("../config-provider");
|
||
|
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;
|
||
|
};
|
||
|
const Overlay = _ref => {
|
||
|
let {
|
||
|
title,
|
||
|
content,
|
||
|
prefixCls
|
||
|
} = _ref;
|
||
|
if (!title && !content) {
|
||
|
return null;
|
||
|
}
|
||
|
return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement("div", {
|
||
|
className: `${prefixCls}-title`
|
||
|
}, title), content && /*#__PURE__*/React.createElement("div", {
|
||
|
className: `${prefixCls}-inner-content`
|
||
|
}, content));
|
||
|
};
|
||
|
exports.Overlay = Overlay;
|
||
|
const RawPurePanel = props => {
|
||
|
const {
|
||
|
hashId,
|
||
|
prefixCls,
|
||
|
className,
|
||
|
style,
|
||
|
placement = 'top',
|
||
|
title,
|
||
|
content,
|
||
|
children
|
||
|
} = props;
|
||
|
const titleNode = (0, _getRenderPropValue.getRenderPropValue)(title);
|
||
|
const contentNode = (0, _getRenderPropValue.getRenderPropValue)(content);
|
||
|
const cls = (0, _classnames.default)(hashId, prefixCls, `${prefixCls}-pure`, `${prefixCls}-placement-${placement}`, className);
|
||
|
return /*#__PURE__*/React.createElement("div", {
|
||
|
className: cls,
|
||
|
style: style
|
||
|
}, /*#__PURE__*/React.createElement("div", {
|
||
|
className: `${prefixCls}-arrow`
|
||
|
}), /*#__PURE__*/React.createElement(_rcTooltip.Popup, Object.assign({}, props, {
|
||
|
className: hashId,
|
||
|
prefixCls: prefixCls
|
||
|
}), children || /*#__PURE__*/React.createElement(Overlay, {
|
||
|
prefixCls: prefixCls,
|
||
|
title: titleNode,
|
||
|
content: contentNode
|
||
|
})));
|
||
|
};
|
||
|
exports.RawPurePanel = RawPurePanel;
|
||
|
const PurePanel = props => {
|
||
|
const {
|
||
|
prefixCls: customizePrefixCls,
|
||
|
className
|
||
|
} = props,
|
||
|
restProps = __rest(props, ["prefixCls", "className"]);
|
||
|
const {
|
||
|
getPrefixCls
|
||
|
} = React.useContext(_configProvider.ConfigContext);
|
||
|
const prefixCls = getPrefixCls('popover', customizePrefixCls);
|
||
|
const [wrapCSSVar, hashId, cssVarCls] = (0, _style.default)(prefixCls);
|
||
|
return wrapCSSVar( /*#__PURE__*/React.createElement(RawPurePanel, Object.assign({}, restProps, {
|
||
|
prefixCls: prefixCls,
|
||
|
hashId: hashId,
|
||
|
className: (0, _classnames.default)(className, cssVarCls)
|
||
|
})));
|
||
|
};
|
||
|
var _default = exports.default = PurePanel;
|