1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- "use strict";
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = Arrow;
- var _classnames = _interopRequireDefault(require("classnames"));
- var React = _interopRequireWildcard(require("react"));
- function Arrow(props) {
- var prefixCls = props.prefixCls,
- align = props.align,
- arrow = props.arrow,
- arrowPos = props.arrowPos;
- var _ref = arrow || {},
- className = _ref.className,
- content = _ref.content;
- var _arrowPos$x = arrowPos.x,
- x = _arrowPos$x === void 0 ? 0 : _arrowPos$x,
- _arrowPos$y = arrowPos.y,
- y = _arrowPos$y === void 0 ? 0 : _arrowPos$y;
- var arrowRef = React.useRef();
- // Skip if no align
- if (!align || !align.points) {
- return null;
- }
- var alignStyle = {
- position: 'absolute'
- };
- // Skip if no need to align
- if (align.autoArrow !== false) {
- var popupPoints = align.points[0];
- var targetPoints = align.points[1];
- var popupTB = popupPoints[0];
- var popupLR = popupPoints[1];
- var targetTB = targetPoints[0];
- var targetLR = targetPoints[1];
- // Top & Bottom
- if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
- alignStyle.top = y;
- } else if (popupTB === 't') {
- alignStyle.top = 0;
- } else {
- alignStyle.bottom = 0;
- }
- // Left & Right
- if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) {
- alignStyle.left = x;
- } else if (popupLR === 'l') {
- alignStyle.left = 0;
- } else {
- alignStyle.right = 0;
- }
- }
- return /*#__PURE__*/React.createElement("div", {
- ref: arrowRef,
- className: (0, _classnames.default)("".concat(prefixCls, "-arrow"), className),
- style: alignStyle
- }, content);
- }
|