index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _motion = require("../../style/motion");
  9. var _internal = require("../../theme/internal");
  10. var _style = require("../../style");
  11. var _placementArrow = _interopRequireWildcard(require("../../style/placementArrow"));
  12. require("vue");
  13. function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
  14. function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
  15. const genTooltipStyle = token => {
  16. const {
  17. componentCls,
  18. // ant-tooltip
  19. tooltipMaxWidth,
  20. tooltipColor,
  21. tooltipBg,
  22. tooltipBorderRadius,
  23. zIndexPopup,
  24. controlHeight,
  25. boxShadowSecondary,
  26. paddingSM,
  27. paddingXS,
  28. tooltipRadiusOuter
  29. } = token;
  30. return [{
  31. [componentCls]: (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  32. position: 'absolute',
  33. zIndex: zIndexPopup,
  34. display: 'block',
  35. '&': [{
  36. width: 'max-content'
  37. }, {
  38. width: 'intrinsic'
  39. }],
  40. maxWidth: tooltipMaxWidth,
  41. visibility: 'visible',
  42. '&-hidden': {
  43. display: 'none'
  44. },
  45. '--antd-arrow-background-color': tooltipBg,
  46. // Wrapper for the tooltip content
  47. [`${componentCls}-inner`]: {
  48. minWidth: controlHeight,
  49. minHeight: controlHeight,
  50. padding: `${paddingSM / 2}px ${paddingXS}px`,
  51. color: tooltipColor,
  52. textAlign: 'start',
  53. textDecoration: 'none',
  54. wordWrap: 'break-word',
  55. backgroundColor: tooltipBg,
  56. borderRadius: tooltipBorderRadius,
  57. boxShadow: boxShadowSecondary
  58. },
  59. // Limit left and right placement radius
  60. [[`&-placement-left`, `&-placement-leftTop`, `&-placement-leftBottom`, `&-placement-right`, `&-placement-rightTop`, `&-placement-rightBottom`].join(',')]: {
  61. [`${componentCls}-inner`]: {
  62. borderRadius: Math.min(tooltipBorderRadius, _placementArrow.MAX_VERTICAL_CONTENT_RADIUS)
  63. }
  64. },
  65. [`${componentCls}-content`]: {
  66. position: 'relative'
  67. }
  68. }), (0, _style.genPresetColor)(token, (colorKey, _ref) => {
  69. let {
  70. darkColor
  71. } = _ref;
  72. return {
  73. [`&${componentCls}-${colorKey}`]: {
  74. [`${componentCls}-inner`]: {
  75. backgroundColor: darkColor
  76. },
  77. [`${componentCls}-arrow`]: {
  78. '--antd-arrow-background-color': darkColor
  79. }
  80. }
  81. };
  82. })), {
  83. // RTL
  84. '&-rtl': {
  85. direction: 'rtl'
  86. }
  87. })
  88. },
  89. // Arrow Style
  90. (0, _placementArrow.default)((0, _internal.mergeToken)(token, {
  91. borderRadiusOuter: tooltipRadiusOuter
  92. }), {
  93. colorBg: 'var(--antd-arrow-background-color)',
  94. showArrowCls: '',
  95. contentRadius: tooltipBorderRadius,
  96. limitVerticalRadius: true
  97. }),
  98. // Pure Render
  99. {
  100. [`${componentCls}-pure`]: {
  101. position: 'relative',
  102. maxWidth: 'none'
  103. }
  104. }];
  105. };
  106. // ============================== Export ==============================
  107. var _default = (prefixCls, injectStyle) => {
  108. const useOriginHook = (0, _internal.genComponentStyleHook)('Tooltip', token => {
  109. // Popover use Tooltip as internal component. We do not need to handle this.
  110. if ((injectStyle === null || injectStyle === void 0 ? void 0 : injectStyle.value) === false) {
  111. return [];
  112. }
  113. const {
  114. borderRadius,
  115. colorTextLightSolid,
  116. colorBgDefault,
  117. borderRadiusOuter
  118. } = token;
  119. const TooltipToken = (0, _internal.mergeToken)(token, {
  120. // default variables
  121. tooltipMaxWidth: 250,
  122. tooltipColor: colorTextLightSolid,
  123. tooltipBorderRadius: borderRadius,
  124. tooltipBg: colorBgDefault,
  125. tooltipRadiusOuter: borderRadiusOuter > 4 ? 4 : borderRadiusOuter
  126. });
  127. return [genTooltipStyle(TooltipToken), (0, _motion.initZoomMotion)(token, 'zoom-big-fast')];
  128. }, _ref2 => {
  129. let {
  130. zIndexPopupBase,
  131. colorBgSpotlight
  132. } = _ref2;
  133. return {
  134. zIndexPopup: zIndexPopupBase + 70,
  135. colorBgDefault: colorBgSpotlight
  136. };
  137. });
  138. return useOriginHook(prefixCls);
  139. };
  140. exports.default = _default;