@aplus-frontend/antdv
Version:
Vue basic component library maintained based on ant-design-vue
141 lines (140 loc) • 5.02 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _motion = require("../../style/motion");
var _internal = require("../../theme/internal");
var _style = require("../../style");
var _placementArrow = _interopRequireWildcard(require("../../style/placementArrow"));
require("vue");
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); }
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 && {}.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; }
const genTooltipStyle = token => {
const {
componentCls,
// ant-tooltip
tooltipMaxWidth,
tooltipColor,
tooltipBg,
tooltipBorderRadius,
zIndexPopup,
controlHeight,
boxShadowSecondary,
paddingSM,
paddingXS,
tooltipRadiusOuter
} = token;
return [{
[componentCls]: (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
position: 'absolute',
zIndex: zIndexPopup,
display: 'block',
'&': [{
width: 'max-content'
}, {
width: 'intrinsic'
}],
maxWidth: tooltipMaxWidth,
visibility: 'visible',
'&-hidden': {
display: 'none'
},
'--antd-arrow-background-color': tooltipBg,
// Wrapper for the tooltip content
[`${componentCls}-inner`]: {
minWidth: controlHeight,
minHeight: controlHeight,
padding: `${paddingSM / 2}px ${paddingXS}px`,
color: tooltipColor,
textAlign: 'start',
textDecoration: 'none',
wordWrap: 'break-word',
backgroundColor: tooltipBg,
borderRadius: tooltipBorderRadius,
boxShadow: boxShadowSecondary
},
// Limit left and right placement radius
[[`&-placement-left`, `&-placement-leftTop`, `&-placement-leftBottom`, `&-placement-right`, `&-placement-rightTop`, `&-placement-rightBottom`].join(',')]: {
[`${componentCls}-inner`]: {
borderRadius: Math.min(tooltipBorderRadius, _placementArrow.MAX_VERTICAL_CONTENT_RADIUS)
}
},
[`${componentCls}-content`]: {
position: 'relative'
}
}), (0, _style.genPresetColor)(token, (colorKey, _ref) => {
let {
darkColor
} = _ref;
return {
[`&${componentCls}-${colorKey}`]: {
[`${componentCls}-inner`]: {
backgroundColor: darkColor
},
[`${componentCls}-arrow`]: {
'--antd-arrow-background-color': darkColor
}
}
};
})), {
// RTL
'&-rtl': {
direction: 'rtl'
}
})
},
// Arrow Style
(0, _placementArrow.default)((0, _internal.mergeToken)(token, {
borderRadiusOuter: tooltipRadiusOuter
}), {
colorBg: 'var(--antd-arrow-background-color)',
showArrowCls: '',
contentRadius: tooltipBorderRadius,
limitVerticalRadius: true
}),
// Pure Render
{
[`${componentCls}-pure`]: {
position: 'relative',
maxWidth: 'none'
}
}];
};
// ============================== Export ==============================
var _default = (prefixCls, injectStyle) => {
const useOriginHook = (0, _internal.genComponentStyleHook)('Tooltip', token => {
// Popover use Tooltip as internal component. We do not need to handle this.
if ((injectStyle === null || injectStyle === void 0 ? void 0 : injectStyle.value) === false) {
return [];
}
const {
borderRadius,
colorTextLightSolid,
colorBgDefault,
borderRadiusOuter
} = token;
const TooltipToken = (0, _internal.mergeToken)(token, {
// default variables
tooltipMaxWidth: 250,
tooltipColor: colorTextLightSolid,
tooltipBorderRadius: borderRadius,
tooltipBg: colorBgDefault,
tooltipRadiusOuter: borderRadiusOuter > 4 ? 4 : borderRadiusOuter
});
return [genTooltipStyle(TooltipToken), (0, _motion.initZoomMotion)(token, 'zoom-big-fast')];
}, _ref2 => {
let {
zIndexPopupBase,
colorBgSpotlight
} = _ref2;
return {
zIndexPopup: zIndexPopupBase + 70,
colorBgDefault: colorBgSpotlight
};
});
return useOriginHook(prefixCls);
};
exports.default = _default;
;