PurePanel.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use client";
  2. import * as React from 'react';
  3. import classNames from 'classnames';
  4. import { Popup } from 'rc-tooltip';
  5. import { ConfigContext } from '../config-provider';
  6. import useStyle from './style';
  7. import { parseColor } from './util';
  8. /** @private Internal Component. Do not use in your production. */
  9. const PurePanel = props => {
  10. const {
  11. prefixCls: customizePrefixCls,
  12. className,
  13. placement = 'top',
  14. title,
  15. color,
  16. overlayInnerStyle
  17. } = props;
  18. const {
  19. getPrefixCls
  20. } = React.useContext(ConfigContext);
  21. const prefixCls = getPrefixCls('tooltip', customizePrefixCls);
  22. const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
  23. // Color
  24. const colorInfo = parseColor(prefixCls, color);
  25. const arrowContentStyle = colorInfo.arrowStyle;
  26. const formattedOverlayInnerStyle = Object.assign(Object.assign({}, overlayInnerStyle), colorInfo.overlayStyle);
  27. const cls = classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-pure`, `${prefixCls}-placement-${placement}`, className, colorInfo.className);
  28. return wrapCSSVar(/*#__PURE__*/React.createElement("div", {
  29. className: cls,
  30. style: arrowContentStyle
  31. }, /*#__PURE__*/React.createElement("div", {
  32. className: `${prefixCls}-arrow`
  33. }), /*#__PURE__*/React.createElement(Popup, Object.assign({}, props, {
  34. className: hashId,
  35. prefixCls: prefixCls,
  36. overlayInnerStyle: formattedOverlayInnerStyle
  37. }), title)));
  38. };
  39. export default PurePanel;